1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -05:00

Add rerunable option and script folder name

This commit is contained in:
Michal Checinski
2023-08-28 15:38:44 +02:00
parent 3d65219f3b
commit d82025b236

View File

@ -24,6 +24,8 @@ public class DbMigrator
}
public bool MigrateMsSqlDatabaseWithRetries(bool enableLogging = true,
bool rerunable = false,
string folderName = "DbScripts",
CancellationToken cancellationToken = default(CancellationToken))
{
var attempt = 1;
@ -32,7 +34,7 @@ public class DbMigrator
{
try
{
var success = MigrateDatabase(enableLogging, cancellationToken);
var success = MigrateDatabase(enableLogging, rerunable, folderName, cancellationToken);
return success;
}
catch (SqlException ex)
@ -54,6 +56,8 @@ public class DbMigrator
}
public bool MigrateDatabase(bool enableLogging = true,
bool rerunable = false,
string folderName = "DbScripts",
CancellationToken cancellationToken = default(CancellationToken))
{
if (_logger != null)
@ -98,9 +102,9 @@ public class DbMigrator
cancellationToken.ThrowIfCancellationRequested();
var builder = DeployChanges.To
.SqlDatabase(_connectionString)
.JournalRerunableToSqlTable("dbo", "Migration")
.JournalRerunableToSqlTable("dbo", "Migration", rerunable)
.WithScriptsAndCodeEmbeddedInAssembly(Assembly.GetExecutingAssembly(),
s => s.Contains($".DbScripts.") && !s.Contains(".Archive."))
s => s.Contains($".{folderName}.") && !s.Contains(".Archive."))
.WithTransaction()
.WithExecutionTimeout(new TimeSpan(0, 5, 0));