我有以下2个gorm型号
// Day is a corresponding day entry
type Day struct {
gorm.Model
Dateday string `json:"dateday" gorm:"type:date;NOT NULL"`
Nameday string `json:"nameday" gorm:"type:varchar(100);NOT NULL"`
Something sql.NullString `json:"something"`
Holyday bool `json:"holyday"`
}
type Week struct {
gorm.Model
Start Day
End Day
}
但是,执行迁移后
db.AutoMigrate(&Day{})
db.AutoMigrate(&Week{})
登录数据库并描述表weeks
postgres-# \d+ weeks;
Table "public.weeks"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
------------+--------------------------+-----------+----------+-----------------------------------+---------+--------------+-------------
id | integer | | not null | nextval('weeks_id_seq'::regclass) | plain | |
created_at | timestamp with time zone | | | | plain | |
updated_at | timestamp with time zone | | | | plain | |
deleted_at | timestamp with time zone | | | | plain | |
Indexes:
"weeks_pkey" PRIMARY KEY, btree (id)
"idx_weeks_deleted_at" btree (deleted_at)
我没有看到start/end字段,它大概也应该是表的外键day(确实存在)
这是为什么?
米琪卡哇伊
相关分类