mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
Migration Fix (#1448)
* created stubs for missing ef provider methods * fixed the initial postgres migration
This commit is contained in:
@ -26,42 +26,15 @@ namespace MySqlMigrations
|
||||
{
|
||||
var globalSettings = GlobalSettingsFactory.GlobalSettings;
|
||||
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
|
||||
|
||||
var selectedDatabaseProvider = globalSettings.DatabaseProvider;
|
||||
var provider = SupportedDatabaseProviders.Postgres;
|
||||
var connectionString = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(selectedDatabaseProvider))
|
||||
var connectionString = globalSettings.MySql?.ConnectionString;
|
||||
if (string.IsNullOrWhiteSpace(connectionString))
|
||||
{
|
||||
switch (selectedDatabaseProvider.ToLowerInvariant())
|
||||
{
|
||||
case "postgres":
|
||||
case "postgresql":
|
||||
provider = SupportedDatabaseProviders.Postgres;
|
||||
connectionString = globalSettings.PostgreSql.ConnectionString;
|
||||
break;
|
||||
case "mysql":
|
||||
case "mariadb":
|
||||
provider = SupportedDatabaseProviders.MySql;
|
||||
connectionString = globalSettings.MySql.ConnectionString;
|
||||
break;
|
||||
default:
|
||||
throw new Exception("No database provider selected");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (provider.Equals(SupportedDatabaseProviders.Postgres))
|
||||
{
|
||||
optionsBuilder.UseNpgsql(
|
||||
connectionString,
|
||||
b => b.MigrationsAssembly("PostgresMigrations"));
|
||||
}
|
||||
else if (provider.Equals(SupportedDatabaseProviders.MySql))
|
||||
{
|
||||
optionsBuilder.UseMySql(
|
||||
connectionString,
|
||||
ServerVersion.AutoDetect(connectionString),
|
||||
b => b.MigrationsAssembly("MySqlMigrations"));
|
||||
throw new Exception("No MySql connection string found.");
|
||||
}
|
||||
optionsBuilder.UseMySql(
|
||||
connectionString,
|
||||
ServerVersion.AutoDetect(connectionString),
|
||||
b => b.MigrationsAssembly("MySqlMigrations"));
|
||||
return new DatabaseContext(optionsBuilder.Options);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user