1 parent f561d51 commit 3b383ebCopy full SHA for 3b383eb
1 file changed
api/pkg/di/container.go
@@ -271,6 +271,11 @@ func (container *Container) DB() (db *gorm.DB) {
271
272
container.logger.Debug(fmt.Sprintf("Running migrations for %T", db))
273
274
+ // This prevents a bug in the Gorm AutoMigrate where it tries to delete this no existent constraints
275
+ db.Exec(`
276
+ALTER TABLE users ADD CONSTRAINT uni_users_api_key CHECK (api_key IS NOT NULL);
277
+ALTER TABLE discords ADD CONSTRAINT uni_discords_server_id CHECK (server_id IS NOT NULL);`)
278
+
279
if err = db.AutoMigrate(&entities.Message{}); err != nil {
280
container.logger.Fatal(stacktrace.Propagate(err, fmt.Sprintf("cannot migrate %T", &entities.Message{})))
281
}
0 commit comments