package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("code_sessions", "代码会话表"). ID("id", 32).Comment("会话ID,主键").End(). String("parent_id", 32).Comment("父会话ID").End(). String("title", 255).NotNull().Default("''").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 Session struct { ID string `gorm:"column:id;type:varchar(32);primaryKey;not null;comment:会话ID,主键"` ParentID string `gorm:"column:parent_id;type:varchar(32);comment:父会话ID"` Title string `gorm:"column:title;type:varchar(255);not null;default:'';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 (Session) TableName() string { return "code_sessions" }