mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-30 16:39:21 +01:00
Change UseMySQLMigrations into a property
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user