Change UseMySQLMigrations into a property

This commit is contained in:
Jordan Brown
2020-03-22 15:25:22 -04:00
parent 5481a096f9
commit 01af820925
3 changed files with 12 additions and 13 deletions
@@ -78,6 +78,11 @@ namespace Tgstation.Server.Host.Database
/// </summary>
protected DatabaseConfiguration DatabaseConfiguration { get; }
/// <summary>
/// Gets a value indicationg whether the MY_ class of migrations should be used instead of the MS_ class
/// </summary>
protected abstract bool UseMySQLMigrations { get; }
/// <summary>
/// The <see cref="IDatabaseSeeder"/> for the <see cref="DatabaseContext{TParentContext}"/>
/// </summary>
@@ -177,12 +182,6 @@ namespace Tgstation.Server.Host.Database
/// <inheritdoc />
public Task Save(CancellationToken cancellationToken) => SaveChangesAsync(cancellationToken);
/// <summary>
/// If the MY_ class of migrations should be used instead of the MS_ class
/// </summary>
/// <returns><see langword="true"/> if the MY_ class of migrations should be used instead of the MS_ class, <see langword="false"/> otherwise</returns>
protected abstract bool UseMySQLMigrations();
/// <inheritdoc />
public async Task SchemaDowngradeForServerVersion(Version version, CancellationToken cancellationToken)
{
@@ -201,7 +200,7 @@ namespace Tgstation.Server.Host.Database
if (targetMigration == null)
return;
if (UseMySQLMigrations())
if (UseMySQLMigrations)
targetMigration = String.Format(CultureInfo.InvariantCulture, "MY{0}", targetMigration.Substring(2));
// even though it clearly implements it in the DatabaseFacade definition this won't work without casting (╯ಠ益ಠ)╯︵ ┻━┻
@@ -13,6 +13,9 @@ namespace Tgstation.Server.Host.Database
/// </summary>
sealed class MySqlDatabaseContext : DatabaseContext<MySqlDatabaseContext>
{
/// <inheritdoc />
protected override bool UseMySQLMigrations => false;
/// <summary>
/// Construct a <see cref="MySqlDatabaseContext"/>
/// </summary>
@@ -38,8 +41,5 @@ namespace Tgstation.Server.Host.Database
else
options.UseMySql(DatabaseConfiguration.ConnectionString);
}
/// <inheritdoc />
protected override bool UseMySQLMigrations() => true;
}
}
@@ -10,6 +10,9 @@ namespace Tgstation.Server.Host.Database
/// </summary>
sealed class SqlServerDatabaseContext : DatabaseContext<SqlServerDatabaseContext>
{
/// <inheritdoc />
protected override bool UseMySQLMigrations => false;
/// <summary>
/// Construct a <see cref="SqlServerDatabaseContext"/>
/// </summary>
@@ -26,8 +29,5 @@ namespace Tgstation.Server.Host.Database
base.OnConfiguring(options);
options.UseSqlServer(DatabaseConfiguration.ConnectionString);
}
/// <inheritdoc />
protected override bool UseMySQLMigrations() => false;
}
}