fix(be): 编辑档案补写到家日期/生日;关迁移期外键修复重复索引
- UpdatePet 的 fields map 之前漏了 birthday 和 arrived_at, 导致编辑档案改到家日期不落库(首页天数一直显示「-」) - DisableForeignKeyConstraintWhenMigrating:外键列自动索引和字段 index tag 撞成同名索引,父子表同迁时报 1061,关掉库级外键约束创建 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,10 @@ func New(cfg *config.Config) (*gorm.DB, error) {
|
||||
TablePrefix: "sundynix_",
|
||||
SingularTable: false,
|
||||
},
|
||||
// 关联在 Go 层管,不靠库级外键。迁移期建外键时 MySQL 会为外键列自动
|
||||
// 补一个索引,和字段上的 `index` tag 撞成同名索引,父子表同迁时第二次
|
||||
// 建索引报 1061 duplicate。关掉外键约束创建,索引就只由 index tag 建一次
|
||||
DisableForeignKeyConstraintWhenMigrating: true,
|
||||
Logger: logger.Default.LogMode(logLevel),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user