move logic for inserting migrations history from MigrateableModuleBase to MigrationUtils
This commit is contained in:
parent
4576f056d5
commit
b76e8498d7
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user