Skip to content

Commit 7f48412

Browse files
committed
Add logic for skipping migrations
1 parent 1ac1dd5 commit 7f48412

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

api/pkg/di/container.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,12 @@ func (container *Container) DB() (db *gorm.DB) {
333333
container.logger.Fatal(stacktrace.Propagate(err, "cannot use GORM tracing plugin"))
334334
}
335335

336-
container.logger.Debug(fmt.Sprintf("Running migrations for %T", db))
336+
if os.Getenv("DATABASE_MIGRATION_SKIP") != "" {
337+
container.logger.Debug(fmt.Sprintf("skipping migrations for [%T]", db))
338+
return container.db
339+
}
337340

341+
container.logger.Debug(fmt.Sprintf("Running migrations for %T", db))
338342
// This prevents a bug in the Gorm AutoMigrate where it tries to delete this no existent constraints
339343
db.Exec(`
340344
ALTER TABLE users ADD CONSTRAINT IF NOT EXISTS uni_users_api_key CHECK (api_key IS NOT NULL);

0 commit comments

Comments
 (0)