1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -05:00

Revert "[DEVOPS-1215] Build migrator CLI project (#2747)" (#2769)

This reverts commit 9cbf254fef.
This commit is contained in:
Michał Chęciński
2023-03-06 18:02:19 +01:00
committed by GitHub
parent 9cbf254fef
commit f8cbd4ef7d
7 changed files with 34 additions and 2912 deletions

View File

@ -23,40 +23,10 @@ public class DbMigrator
}.ConnectionString;
}
public bool MigrateMsSqlDatabaseWithRetries(bool enableLogging = true,
public bool MigrateMsSqlDatabase(bool enableLogging = true,
CancellationToken cancellationToken = default(CancellationToken))
{
var attempt = 1;
while (attempt < 10)
{
try
{
var success = MigrateDatabase(enableLogging, cancellationToken);
return success;
}
catch (SqlException ex)
{
if (ex.Message.Contains("Server is in script upgrade mode"))
{
attempt++;
_logger.LogInformation("Database is in script upgrade mode. " +
$"Trying again (attempt #{attempt})...");
Thread.Sleep(20000);
}
else
{
throw;
}
}
}
return false;
}
public bool MigrateDatabase(bool enableLogging = true,
CancellationToken cancellationToken = default(CancellationToken))
{
if (_logger != null)
if (enableLogging && _logger != null)
{
_logger.LogInformation(Constants.BypassFiltersEventId, "Migrating database.");
}
@ -119,7 +89,7 @@ public class DbMigrator
var upgrader = builder.Build();
var result = upgrader.PerformUpgrade();
if (_logger != null)
if (enableLogging && _logger != null)
{
if (result.Successful)
{