feat(migration): added migration toggle
This commit is contained in:
parent
d5f0d3ee8c
commit
e53fd2c9a5
@ -70,9 +70,11 @@ func Connect(ctx context.Context, config models.DatabaseConfig) error {
|
|||||||
return utils.HandleError(ctx, span, localLogger, err)
|
return utils.HandleError(ctx, span, localLogger, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = migrateDatabase(ctx, sqlDB, config)
|
if config.Migrate {
|
||||||
if err != nil {
|
err = migrateDatabase(ctx, sqlDB, config)
|
||||||
return utils.HandleError(ctx, span, localLogger, err)
|
if err != nil {
|
||||||
|
return utils.HandleError(ctx, span, localLogger, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client = sqlDB
|
client = sqlDB
|
||||||
|
@ -9,4 +9,5 @@ type DatabaseConfig struct {
|
|||||||
SSL bool `env:"DB_SSL,required" envDefault:"true"`
|
SSL bool `env:"DB_SSL,required" envDefault:"true"`
|
||||||
Timezone string `env:"DB_TIMEZONE,required" envDefault:"Europe/Berlin"`
|
Timezone string `env:"DB_TIMEZONE,required" envDefault:"Europe/Berlin"`
|
||||||
Debug bool `env:"DB_DEBUG" envDefault:"false"`
|
Debug bool `env:"DB_DEBUG" envDefault:"false"`
|
||||||
|
Migrate bool
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,7 @@ func DatabaseModesFromConnectionString(ctx context.Context, pgContainer *postgre
|
|||||||
SSL: false,
|
SSL: false,
|
||||||
Timezone: "Europe/Berlin",
|
Timezone: "Europe/Berlin",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
Migrate: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
return databaseConfig, nil
|
return databaseConfig, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user