mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
This reverts commit f8cbd4ef7d
.
This commit is contained in:
@ -23,10 +23,40 @@ public class DbMigrator
|
||||
}.ConnectionString;
|
||||
}
|
||||
|
||||
public bool MigrateMsSqlDatabase(bool enableLogging = true,
|
||||
public bool MigrateMsSqlDatabaseWithRetries(bool enableLogging = true,
|
||||
CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
if (enableLogging && _logger != null)
|
||||
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)
|
||||
{
|
||||
_logger.LogInformation(Constants.BypassFiltersEventId, "Migrating database.");
|
||||
}
|
||||
@ -89,7 +119,7 @@ public class DbMigrator
|
||||
var upgrader = builder.Build();
|
||||
var result = upgrader.PerformUpgrade();
|
||||
|
||||
if (enableLogging && _logger != null)
|
||||
if (_logger != null)
|
||||
{
|
||||
if (result.Successful)
|
||||
{
|
||||
|
Reference in New Issue
Block a user