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,12 +9,16 @@ namespace Oqtane.Migrations
{
[DbContext(typeof(TenantDBContext))]
[Migration("Tenant.02.00.01.03")]
public class UpdatePageAndAddColumnToSite : Migration
public class UpdatePageAndAddColumnToSite : MultiDatabaseMigration
{
public UpdatePageAndAddColumnToSite(IEnumerable<IOqtaneDatabase> databases) : base(databases)
{
}
protected override void Up(MigrationBuilder migrationBuilder)
{
//Add Column to Site table
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder, ActiveDatabase);
siteEntityBuilder.AddStringColumn("AdminContainerType", 200, true);
//Update new column
@ -25,8 +31,8 @@ namespace Oqtane.Migrations
//Delete records from Page
migrationBuilder.Sql(
@"
DELETE FROM [Page]
WHERE Path = 'admin/tenants';
DELETE FROM Page
WHERE Path = 'admin/tenants'
");
}
@ -34,7 +40,7 @@ namespace Oqtane.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
//Drop Column from Site table
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder, ActiveDatabase);
siteEntityBuilder.DropColumn("AdminContainerType");
}
}