1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-04 20:50:21 -05:00
bitwarden/util/Migrator/SqlServerDbMigrator.cs
Matt Bishop 743465273c
[PM-6909] Centralize database migration logic (#3910)
* Centralize database migration logic

* Clean up unused usings

* Prizatize

* Remove verbose flag from Docker invocation

* Allow argument passthrough still

Co-authored-by: Michał Chęciński <mchecinski@bitwarden.com>

* Allow DI logger

---------

Co-authored-by: Michał Chęciński <mchecinski@bitwarden.com>
2024-03-22 10:54:13 -04:00

23 lines
650 B
C#

using Bit.Core.Settings;
using Bit.Core.Utilities;
using Microsoft.Extensions.Logging;
namespace Bit.Migrator;
public class SqlServerDbMigrator : IDbMigrator
{
private readonly DbMigrator _migrator;
public SqlServerDbMigrator(GlobalSettings globalSettings, ILogger<DbMigrator> logger)
{
_migrator = new DbMigrator(globalSettings.SqlServer.ConnectionString, logger);
}
public bool MigrateDatabase(bool enableLogging = true,
CancellationToken cancellationToken = default)
{
return _migrator.MigrateMsSqlDatabaseWithRetries(enableLogging,
cancellationToken: cancellationToken);
}
}