Added suuport to inject an IOqtaneDatabase in EntityBuilders to allow each Database to control certain Migration behaviors. Also updated Installer to dynamically build Database Configuration section

This commit is contained in:
Charles Nurse
2021-03-27 11:16:16 -07:00
parent 3a032f401a
commit 2fb63e8117
74 changed files with 1028 additions and 407 deletions

View File

@ -1,5 +1,7 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Oqtane.Interfaces;
using Oqtane.Migrations.EntityBuilders;
using Oqtane.Repository;
@ -7,14 +9,18 @@ namespace Oqtane.Migrations
{
[DbContext(typeof(TenantDBContext))]
[Migration("Tenant.01.00.02.01")]
public class DropColumnFromPage : Migration
public class DropColumnFromPage : MultiDatabaseMigration
{
public DropColumnFromPage(IEnumerable<IOqtaneDatabase> databases) : base(databases)
{
}
protected override void Up(MigrationBuilder migrationBuilder)
{
//Drop Column from Page table
if (migrationBuilder.ActiveProvider == "Microsoft.EntityFrameworkCore.SqlServer")
if (ActiveDatabase.Name == "SqlServer" || ActiveDatabase.Name == "LocalDB")
{
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder, ActiveDatabase);
pageEntityBuilder.DropColumn("EditMode");
}
}
@ -22,7 +28,7 @@ namespace Oqtane.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
//Add Column to Page table
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder, ActiveDatabase);
pageEntityBuilder.AddBooleanColumn("EditMode");
}
}