提交 2ed73cae 编写于 作者: Sliver_Horn's avatar Sliver_Horn

对gorm生成的外键表多s问题作出兼容代码

上级 f5369c79
......@@ -411,7 +411,13 @@ func InitSysDataAuthorityId() (err error) {
{"9528", "8881"},
{"9528", "9528"},
}
if tx.Table("sys_data_authority_ids").Create(&insert).Error != nil { // 遇到错误时回滚事务
if global.GVA_DB.Migrator().HasTable("sys_data_authority_ids") {
if tx.Table("sys_data_authority_ids").Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
}
if tx.Table("sys_data_authority_id").Create(&insert).Error != nil { // 遇到错误时回滚事务
tx.Rollback()
}
return tx.Commit().Error
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册