From 01af82092563cbbd1f09fb73fd987eec290e89a0 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Sun, 22 Mar 2020 15:24:16 -0400 Subject: [PATCH] Change UseMySQLMigrations into a property --- .../Database/DatabaseContext.cs | 13 ++++++------- .../Database/MySqlDatabaseContext.cs | 6 +++--- .../Database/SqlServerDatabaseContext.cs | 6 +++--- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs index 5be860c5a5..eff5c5df95 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs @@ -78,6 +78,11 @@ namespace Tgstation.Server.Host.Database /// protected DatabaseConfiguration DatabaseConfiguration { get; } + /// + /// Gets a value indicationg whether the MY_ class of migrations should be used instead of the MS_ class + /// + protected abstract bool UseMySQLMigrations { get; } + /// /// The for the /// @@ -177,12 +182,6 @@ namespace Tgstation.Server.Host.Database /// public Task Save(CancellationToken cancellationToken) => SaveChangesAsync(cancellationToken); - /// - /// If the MY_ class of migrations should be used instead of the MS_ class - /// - /// if the MY_ class of migrations should be used instead of the MS_ class, otherwise - protected abstract bool UseMySQLMigrations(); - /// 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 (╯ಠ益ಠ)╯︵ ┻━┻ diff --git a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs index 593aa93519..b061b0e362 100644 --- a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs @@ -13,6 +13,9 @@ namespace Tgstation.Server.Host.Database /// sealed class MySqlDatabaseContext : DatabaseContext { + /// + protected override bool UseMySQLMigrations => false; + /// /// Construct a /// @@ -38,8 +41,5 @@ namespace Tgstation.Server.Host.Database else options.UseMySql(DatabaseConfiguration.ConnectionString); } - - /// - protected override bool UseMySQLMigrations() => true; } } diff --git a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs index 0acda9944f..caf7d334a5 100644 --- a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs @@ -10,6 +10,9 @@ namespace Tgstation.Server.Host.Database /// sealed class SqlServerDatabaseContext : DatabaseContext { + /// + protected override bool UseMySQLMigrations => false; + /// /// Construct a /// @@ -26,8 +29,5 @@ namespace Tgstation.Server.Host.Database base.OnConfiguring(options); options.UseSqlServer(DatabaseConfiguration.ConnectionString); } - - /// - protected override bool UseMySQLMigrations() => false; } }