File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -321,6 +321,12 @@ func (container *Container) DB() (db *gorm.DB) {
321321
322322 container .logger .Debug (fmt .Sprintf ("Running migrations for %T" , db ))
323323
324+ // This prevents a bug in the Gorm AutoMigrate where it tries to delete this no existent constraints
325+ db .Exec (`
326+ ALTER TABLE users ADD CONSTRAINT IF NOT EXISTS uni_users_api_key CHECK (api_key IS NOT NULL);
327+ ALTER TABLE phone_api_keys ADD CONSTRAINT IF NOT EXISTS uni_phone_api_keys_api_key CHECK (api_key IS NOT NULL);
328+ ALTER TABLE discords ADD CONSTRAINT IF NOT EXISTS uni_discords_server_id CHECK (server_id IS NOT NULL);` )
329+
324330 if err = db .AutoMigrate (& entities.Message {}); err != nil {
325331 container .logger .Fatal (stacktrace .Propagate (err , fmt .Sprintf ("cannot migrate %T" , & entities.Message {})))
326332 }
You can’t perform that action at this time.
0 commit comments