Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Add logic for skipping migrations

Acho Arnold7f48412ae995
diff --git a/api/pkg/di/container.go b/api/pkg/di/container.go
index 7f88251a..632e4706 100644
--- a/api/pkg/di/container.go
+++ b/api/pkg/di/container.go
@@ -333,8 +333,12 @@ func (container *Container) DB() (db *gorm.DB) {
container.logger.Fatal(stacktrace.Propagate(err, "cannot use GORM tracing plugin"))
}
- container.logger.Debug(fmt.Sprintf("Running migrations for %T", db))
+ if os.Getenv("DATABASE_MIGRATION_SKIP") != "" {
+ container.logger.Debug(fmt.Sprintf("skipping migrations for [%T]", db))
+ return container.db
+ }
+ container.logger.Debug(fmt.Sprintf("Running migrations for %T", db))
// This prevents a bug in the Gorm AutoMigrate where it tries to delete this no existent constraints
db.Exec(`
ALTER TABLE users ADD CONSTRAINT IF NOT EXISTS uni_users_api_key CHECK (api_key IS NOT NULL);