Move Migrations into Master and Tenant folders so its clear what type of Migration is being applied

This commit is contained in:
Charles Nurse
2021-05-25 12:16:10 -07:00
parent 7ec3376308
commit 077b866e8c
17 changed files with 20 additions and 54 deletions

View File

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Databases.Interfaces;
using Oqtane.Migrations.EntityBuilders;
using Oqtane.Repository;
namespace Oqtane.Migrations.Tenant
{
[DbContext(typeof(TenantDBContext))]
[Migration("Tenant.02.01.00.01")]
public class ChangeFolderNameAndPathColumnsSize : MultiDatabaseMigration
{
public ChangeFolderNameAndPathColumnsSize(IDatabase database) : base(database)
{
}
protected override void Up(MigrationBuilder migrationBuilder)
{
var folderEntityBuilder = new FolderEntityBuilder(migrationBuilder, ActiveDatabase);
folderEntityBuilder.AlterStringColumn("Name", 256);
// Drop the index is needed because the Path is already associated with IX_Folder
folderEntityBuilder.DropForeignKey("FK_Folder_Site");
folderEntityBuilder.DropIndex("IX_Folder");
folderEntityBuilder.AlterStringColumn("Path", 512);
folderEntityBuilder.AddIndex("IX_Folder", new[] { "SiteId", "Path" }, true);
folderEntityBuilder.AddForeignKey("FK_Folder_Site");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
var folderEntityBuilder = new FolderEntityBuilder(migrationBuilder, ActiveDatabase);
folderEntityBuilder.AlterStringColumn("Name", 50);
folderEntityBuilder.DropIndex("IX_Folder");
folderEntityBuilder.AlterStringColumn("Path", 50);
folderEntityBuilder.AddIndex("IX_Folder", new[] { "SiteId", "Path" }, true);
}
}
}