diff --git a/pkg/database/client.go b/pkg/database/client.go index 1fadda5..7618372 100644 --- a/pkg/database/client.go +++ b/pkg/database/client.go @@ -70,9 +70,11 @@ func Connect(ctx context.Context, config models.DatabaseConfig) error { return utils.HandleError(ctx, span, localLogger, err) } - err = migrateDatabase(ctx, sqlDB, config) - if err != nil { - return utils.HandleError(ctx, span, localLogger, err) + if config.Migrate { + err = migrateDatabase(ctx, sqlDB, config) + if err != nil { + return utils.HandleError(ctx, span, localLogger, err) + } } client = sqlDB diff --git a/pkg/models/config.go b/pkg/models/config.go index 2013b95..e98a58f 100644 --- a/pkg/models/config.go +++ b/pkg/models/config.go @@ -9,4 +9,5 @@ type DatabaseConfig struct { SSL bool `env:"DB_SSL,required" envDefault:"true"` Timezone string `env:"DB_TIMEZONE,required" envDefault:"Europe/Berlin"` Debug bool `env:"DB_DEBUG" envDefault:"false"` + Migrate bool } diff --git a/test/helper.go b/test/helper.go index 49155fa..aa12b0e 100644 --- a/test/helper.go +++ b/test/helper.go @@ -121,6 +121,7 @@ func DatabaseModesFromConnectionString(ctx context.Context, pgContainer *postgre SSL: false, Timezone: "Europe/Berlin", Debug: true, + Migrate: true, } return databaseConfig, nil