mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[PM-6938] Allow certain database operations to be skipped (#3914)
* Centralize database migration logic * Clean up unused usings * Prizatize * Remove verbose flag from Docker invocation * Allow certain database operations to be skipped * Readonly
This commit is contained in:
@ -13,11 +13,14 @@ public class DbMigrator
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly ILogger<DbMigrator> _logger;
|
||||
private readonly bool _skipDatabasePreparation;
|
||||
|
||||
public DbMigrator(string connectionString, ILogger<DbMigrator> logger = null)
|
||||
public DbMigrator(string connectionString, ILogger<DbMigrator> logger = null,
|
||||
bool skipDatabasePreparation = false)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger ?? CreateLogger();
|
||||
_skipDatabasePreparation = skipDatabasePreparation;
|
||||
}
|
||||
|
||||
public bool MigrateMsSqlDatabaseWithRetries(bool enableLogging = true,
|
||||
@ -31,7 +34,10 @@ public class DbMigrator
|
||||
{
|
||||
try
|
||||
{
|
||||
PrepareDatabase(cancellationToken);
|
||||
if (!_skipDatabasePreparation)
|
||||
{
|
||||
PrepareDatabase(cancellationToken);
|
||||
}
|
||||
|
||||
var success = MigrateDatabase(enableLogging, repeatable, folderName, dryRun, cancellationToken);
|
||||
return success;
|
||||
|
Reference in New Issue
Block a user