mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
This reverts commit 9cbf254fef
.
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.Net.Http.Json;
|
||||
using Bit.Migrator;
|
||||
using Microsoft.Data.SqlClient;
|
||||
|
||||
namespace Bit.Setup;
|
||||
|
||||
@ -186,10 +187,35 @@ public class Program
|
||||
|
||||
private static void MigrateDatabase(int attempt = 1)
|
||||
{
|
||||
var vaultConnectionString = Helpers.GetValueFromEnvFile("global",
|
||||
"globalSettings__sqlServer__connectionString");
|
||||
var migrator = new DbMigrator(vaultConnectionString, null);
|
||||
migrator.MigrateMsSqlDatabaseWithRetries(false);
|
||||
try
|
||||
{
|
||||
Helpers.WriteLine(_context, "Migrating database.");
|
||||
var vaultConnectionString = Helpers.GetValueFromEnvFile("global",
|
||||
"globalSettings__sqlServer__connectionString");
|
||||
var migrator = new DbMigrator(vaultConnectionString, null);
|
||||
var success = migrator.MigrateMsSqlDatabase(false);
|
||||
if (success)
|
||||
{
|
||||
Helpers.WriteLine(_context, "Migration successful.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Helpers.WriteLine(_context, "Migration failed.");
|
||||
}
|
||||
}
|
||||
catch (SqlException e)
|
||||
{
|
||||
if (e.Message.Contains("Server is in script upgrade mode") && attempt < 10)
|
||||
{
|
||||
var nextAttempt = attempt + 1;
|
||||
Helpers.WriteLine(_context, "Database is in script upgrade mode. " +
|
||||
"Trying again (attempt #{0})...", nextAttempt);
|
||||
System.Threading.Thread.Sleep(20000);
|
||||
MigrateDatabase(nextAttempt);
|
||||
return;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ValidateInstallation()
|
||||
|
Reference in New Issue
Block a user