diff --git a/Oqtane.Server/Migrations/Framework/MigrationUtils.cs b/Oqtane.Server/Migrations/Framework/MigrationUtils.cs index a2b78934..a905a310 100644 --- a/Oqtane.Server/Migrations/Framework/MigrationUtils.cs +++ b/Oqtane.Server/Migrations/Framework/MigrationUtils.cs @@ -38,5 +38,14 @@ namespace Oqtane.Migrations.Framework .ToString(); } + // only used in upgrade scenarios for modules that used SQL scripts originally + public static string BuildInsertScript(string MigrationId) + { + var query = "IF NOT EXISTS(SELECT 1 FROM __EFMigrationsHistory WHERE MigrationId = '" + MigrationId + "') "; + query += "INSERT INTO __EFMigrationsHistory(MigrationId, ProductVersion, AppliedDate, AppliedVersion) "; + query += "VALUES('" + MigrationId + "', '5.0.0', SYSDATETIME(), '" + Constants.Version + "')"; + return query; + } + } } diff --git a/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs b/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs index ba190654..d38183b2 100644 --- a/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs +++ b/Oqtane.Server/Modules/HtmlText/Manager/HtmlTextManager.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Http; using Oqtane.Enums; using Oqtane.Repository; using Oqtane.Shared; +using Oqtane.Migrations.Framework; // ReSharper disable ConvertToUsingDeclaration @@ -60,7 +61,7 @@ namespace Oqtane.Modules.HtmlText.Manager if (tenant.DBType == Constants.DefaultDBType && version == "1.0.1") { // version 1.0.0 used SQL scripts rather than migrations, so we need to seed the migration history table - AddMigrationHistory(_sqlRepository, tenant, "HtmlText.01.00.00.00"); + _sqlRepository.ExecuteNonQuery(tenant, MigrationUtils.BuildInsertScript("HtmlText.01.00.00.00")); } return Migrate(new HtmlTextContext(_tenantManager, _accessor), tenant, MigrationType.Up); } diff --git a/Oqtane.Server/Modules/MigratableModuleBase.cs b/Oqtane.Server/Modules/MigratableModuleBase.cs index d97cc86d..11dbc081 100644 --- a/Oqtane.Server/Modules/MigratableModuleBase.cs +++ b/Oqtane.Server/Modules/MigratableModuleBase.cs @@ -38,13 +38,5 @@ namespace Oqtane.Modules return result; } - - public void AddMigrationHistory(ISqlRepository sqlRepository, Tenant tenant, string MigrationId) - { - var query = "IF NOT EXISTS(SELECT 1 FROM __EFMigrationsHistory WHERE MigrationId = '" + MigrationId + "') "; - query += "INSERT INTO __EFMigrationsHistory(MigrationId, ProductVersion, AppliedDate, AppliedVersion) "; - query += "VALUES('" + MigrationId + "', '5.0.0', SYSDATETIME(), '" + Constants.Version + "')"; - sqlRepository.ExecuteNonQuery(tenant, query); - } } }