package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("code_projects", "代码项目表"). ID("id", 32).Comment("项目ID,主键").End(). String("name", 255).NotNull().Comment("项目名称").End(). String("description", 1024).Comment("项目描述").End(). String("path", 512).NotNull().Comment("项目目录路径").End(). String("tenant_id", 8).NotNull().Comment("租户ID").End(). String("creator", 32).NotNull().Comment("创建人").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End(). DateTime("updated_at").NotNull().Default("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP").Comment("更新时间").End() r.RegisterTable(tb.Build()) }) } type Project struct { ID string `gorm:"column:id;type:varchar(32);primaryKey;not null;comment:项目ID,主键"` Name string `gorm:"column:name;type:varchar(255);not null;comment:项目名称"` Description string `gorm:"column:description;type:varchar(1024);comment:项目描述"` Path string `gorm:"column:path;type:varchar(512);not null;comment:项目目录路径"` TenantID string `gorm:"column:tenant_id;type:varchar(8);not null;comment:租户ID"` Creator string `gorm:"column:creator;type:varchar(32);not null;comment:创建人"` CreatedAt time.Time `gorm:"column:created_at;not null;default:CURRENT_TIMESTAMP;comment:创建时间"` UpdatedAt time.Time `gorm:"column:updated_at;not null;default:CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;comment:更新时间"` } func (Project) TableName() string { return "code_projects" }