mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[PM-6909] Centralize database migration logic (#3910)
* Centralize database migration logic * Clean up unused usings * Prizatize * Remove verbose flag from Docker invocation * Allow argument passthrough still Co-authored-by: Michał Chęciński <mchecinski@bitwarden.com> * Allow DI logger --------- Co-authored-by: Michał Chęciński <mchecinski@bitwarden.com>
This commit is contained in:
@ -17,6 +17,7 @@ public class Program
|
||||
{
|
||||
Args = args
|
||||
};
|
||||
|
||||
ParseParameters();
|
||||
|
||||
if (_context.Parameters.ContainsKey("q"))
|
||||
@ -155,7 +156,7 @@ public class Program
|
||||
|
||||
if (_context.Parameters.ContainsKey("db"))
|
||||
{
|
||||
MigrateDatabase();
|
||||
PrepareAndMigrateDatabase();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -185,17 +186,19 @@ public class Program
|
||||
Console.WriteLine("\n");
|
||||
}
|
||||
|
||||
private static void MigrateDatabase(int attempt = 1)
|
||||
private static void PrepareAndMigrateDatabase()
|
||||
{
|
||||
var vaultConnectionString = Helpers.GetValueFromEnvFile("global",
|
||||
"globalSettings__sqlServer__connectionString");
|
||||
var migrator = new DbMigrator(vaultConnectionString, null);
|
||||
var migrator = new DbMigrator(vaultConnectionString);
|
||||
|
||||
var log = false;
|
||||
var enableLogging = false;
|
||||
|
||||
migrator.MigrateMsSqlDatabaseWithRetries(log);
|
||||
// execute all general migration scripts (will detect those not yet applied)
|
||||
migrator.MigrateMsSqlDatabaseWithRetries(enableLogging);
|
||||
|
||||
migrator.MigrateMsSqlDatabaseWithRetries(log, true, MigratorConstants.TransitionMigrationsFolderName);
|
||||
// execute explicit transition migration scripts, per EDD
|
||||
migrator.MigrateMsSqlDatabaseWithRetries(enableLogging, true, MigratorConstants.TransitionMigrationsFolderName);
|
||||
}
|
||||
|
||||
private static bool ValidateInstallation()
|
||||
|
Reference in New Issue
Block a user