package tables import ( "time" "git.x2erp.com/qdy/go-db/sqldef" ) func init() { sqldef.AddRegistration(func(r *sqldef.Registry) { tb := sqldef.NewTable("config_project_skill", "配置项目Skill表"). ID("id", 128).NotNull().Comment("主键").End(). String("skill_id", 128).NotNull().Comment("Skill ID").End(). String("description", 256).NotNull().Default("''").Comment("描述").End(). JSON("content").NotNull().Comment("Skill内容 (JSON格式)").End(). String("project_id", 128).NotNull().Comment("项目ID").End(). String("creator", 32).NotNull().Comment("创建人").End(). DateTime("created_at").NotNull().Default("CURRENT_TIMESTAMP").Comment("创建时间").End() tb.AddIndex("idx_skill_id", "skill_id") tb.AddIndex("idx_project_id", "project_id") r.RegisterTable(tb.Build()) }) } type ProjectSkill struct { SkillID string `gorm:"column:skill_id;type:varchar(128);not null;primaryKey;comment:Skill ID"` Description string `gorm:"column:description;type:varchar(256);not null;default:'';comment:描述"` Content string `gorm:"column:content;type:json;not null;comment:Skill内容 (JSON格式)"` ProjectID string `gorm:"column:project_id;type:varchar(128);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:创建时间"` } type ProjectSkillDB struct { ID string `db:"id"` SkillID string `db:"skill_id"` Description string `db:"description"` Content string `db:"content"` ProjectID string `db:"project_id"` Creator string `db:"creator"` CreatedAt time.Time `db:"created_at"` } func (ProjectSkill) TableName() string { return "config_project_skill" }