| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package tables
-
- import (
- "time"
-
- "git.x2erp.com/qdy/go-db/sqldef"
- )
-
- func init() {
- sqldef.AddRegistration(func(r *sqldef.Registry) {
- tb := sqldef.NewTable("dic_table_alias", "数据库表别名字典表 - 管理数据库表别名字典,比如调拨单(表),又会叫移库单,移仓单").
- ID("id", 50).NotNull().Comment("主键").End().
- String("table_id", 64).NotNull().Comment("表ID").End().
- String("table_alias", 50).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().
- DateTime("deleted_at").Comment("删除时间").End()
-
- tb.AddIndex("idx_table_id", "table_id")
- tb.AddIndex("idx_table_alias", "table_alias")
- tb.AddUniqueIndex("uk_table_alias", "table_alias")
-
- r.RegisterTable(tb.Build())
- })
- }
-
- type DicTableAlias struct {
- ID string `gorm:"column:id;type:varchar(50);not null;primaryKey;comment:主键"`
- TableID string `gorm:"column:table_id;type:varchar(64);not null;comment:表ID"`
- TableAlias string `gorm:"column:table_alias;type:varchar(50);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:更新时间"`
- DeletedAt *time.Time `gorm:"column:deleted_at;comment:删除时间"`
- }
-
- type DicTableAliasDB struct {
- ID string `db:"id" json:"id"`
- TableID string `db:"table_id" json:"tableID"`
- TableAlias string `db:"table_alias" json:"tableAlias"`
- CreatedAt time.Time `db:"created_at" json:"createdAt"`
- UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
- DeletedAt *time.Time `db:"deleted_at" json:"deletedAt"`
- }
-
- func (DicTableAlias) TableName() string {
- return "dic_table_alias"
- }
|