package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("config_project", "配置项目表"). ID("id", 128).NotNull().Comment("主键").End(). String("project_id", 128).NotNull().Comment("项目ID").End(). String("description", 256).NotNull().Default("''").Comment("项目描述").End(). String("mcp_url", 256).NotNull().Default("''").Comment("MCP服务地址").End(). String("creator", 32).NotNull().Comment("创建人").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End() tb.AddIndex("idx_project_id", "project_id") r.RegisterTable(tb.Build()) }) } type Project struct { ProjectID string `gorm:"column:project_id;type:varchar(128);not null;primaryKey;comment:项目ID"` Description string `gorm:"column:description;type:varchar(256);not null;default:'';comment:项目描述"` McpURL string `gorm:"column:mcp_url;type:varchar(256);not null;default:'';comment:MCP服务地址"` Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"` CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"` } type ProjectDB struct { ID string `db:"id"` ProjectID string `db:"project_id"` Description string `db:"description"` McpURL string `db:"mcp_url"` Creator string `db:"creator"` CreatedAt time.Time `db:"created_at"` } func (Project) TableName() string { return "config_project" }