moved AlterStringColumn to IDatabase interface so that it can be overridden in the Sqlite provider rather than requiring conditional logic in the migrations

This commit is contained in:
Shaun Walker
2022-02-22 14:47:31 -05:00
parent 3d0cbdd1a7
commit 9ba356c47e
11 changed files with 51 additions and 68 deletions

View File

@ -16,29 +16,20 @@ namespace Oqtane.Migrations.Tenant
protected override void Up(MigrationBuilder migrationBuilder)
{
if (ActiveDatabase.Name != "Sqlite")
{
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder, ActiveDatabase);
// Drop the index is needed because the Name is already associated with IX_File
fileEntityBuilder.DropForeignKey("FK_File_Folder");
fileEntityBuilder.DropIndex("IX_File");
fileEntityBuilder.AlterStringColumn("Name", 256);
fileEntityBuilder.AddIndex("IX_File", new[] { "FolderId", "Name" }, true);
fileEntityBuilder.AddForeignKey("FK_File_Folder");
}
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder, ActiveDatabase);
// Drop the index is needed because the Name is already associated with IX_File
fileEntityBuilder.DropIndex("IX_File");
fileEntityBuilder.AlterStringColumn("Name", 256);
fileEntityBuilder.AddIndex("IX_File", new[] { "FolderId", "Name" }, true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
if (ActiveDatabase.Name != "Sqlite")
{
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder, ActiveDatabase);
fileEntityBuilder.DropIndex("IX_File");
fileEntityBuilder.AlterStringColumn("Name", 50);
fileEntityBuilder.AddIndex("IX_File", new[] { "FolderId", "Name" }, true);
}
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder, ActiveDatabase);
// Drop the index is needed because the Name is already associated with IX_File
fileEntityBuilder.DropIndex("IX_File");
fileEntityBuilder.AlterStringColumn("Name", 50);
fileEntityBuilder.AddIndex("IX_File", new[] { "FolderId", "Name" }, true);
}
}
}