2024-03-22 15:54:13 +01:00
|
|
|
|
using Bit.Core.Settings;
|
2022-11-18 20:39:01 +01:00
|
|
|
|
using Bit.Core.Utilities;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Migrator;
|
|
|
|
|
|
|
|
|
|
public class SqlServerDbMigrator : IDbMigrator
|
|
|
|
|
{
|
2024-03-22 15:54:13 +01:00
|
|
|
|
private readonly DbMigrator _migrator;
|
2022-11-18 20:39:01 +01:00
|
|
|
|
|
2024-03-22 15:54:13 +01:00
|
|
|
|
public SqlServerDbMigrator(GlobalSettings globalSettings, ILogger<DbMigrator> logger)
|
2022-11-18 20:39:01 +01:00
|
|
|
|
{
|
2024-03-27 16:20:54 +01:00
|
|
|
|
_migrator = new DbMigrator(globalSettings.SqlServer.ConnectionString, logger,
|
|
|
|
|
globalSettings.SqlServer.SkipDatabasePreparation);
|
2022-11-18 20:39:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool MigrateDatabase(bool enableLogging = true,
|
2024-03-22 15:54:13 +01:00
|
|
|
|
CancellationToken cancellationToken = default)
|
2022-11-18 20:39:01 +01:00
|
|
|
|
{
|
2024-03-22 15:54:13 +01:00
|
|
|
|
return _migrator.MigrateMsSqlDatabaseWithRetries(enableLogging,
|
|
|
|
|
cancellationToken: cancellationToken);
|
2022-11-18 20:39:01 +01:00
|
|
|
|
}
|
|
|
|
|
}
|