修复gorm自动创建无用外键的问题
This commit is contained in:
@@ -70,6 +70,9 @@ func (ps *PostgresStorage) Connect() error {
|
||||
sqlDB.SetMaxIdleConns(ps.maxIdleConns)
|
||||
sqlDB.SetConnMaxLifetime(time.Duration(ps.connMaxLifetime) * time.Second)
|
||||
|
||||
// gorm会根据字段名自动创建外键约束, 但触发器Task的PlanID是不存在的, 所以需要关闭, 这个关闭对
|
||||
ps.db.DisableForeignKeyConstraintWhenMigrating = true
|
||||
|
||||
ps.logger.Info("PostgreSQL数据库连接成功")
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user