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:
@ -1,5 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations;
|
||||
using Oqtane.Modules.HtmlText.Migrations.EntityBuilders;
|
||||
using Oqtane.Modules.HtmlText.Repository;
|
||||
|
||||
@ -7,19 +10,23 @@ namespace Oqtane.Modules.HtmlText.Migrations
|
||||
{
|
||||
[DbContext(typeof(HtmlTextContext))]
|
||||
[Migration("HtmlText.01.00.00.00")]
|
||||
public class InitializeModule : Migration
|
||||
public class InitializeModule : MultiDatabaseMigration
|
||||
{
|
||||
public InitializeModule(IEnumerable<IOqtaneDatabase> databases) : base(databases)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
//Create HtmlText table
|
||||
var entityBuilder = new HtmlTextEntityBuilder(migrationBuilder);
|
||||
var entityBuilder = new HtmlTextEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Create();
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
//Drop HtmlText table
|
||||
var entityBuilder = new HtmlTextEntityBuilder(migrationBuilder);
|
||||
var entityBuilder = new HtmlTextEntityBuilder(migrationBuilder, ActiveDatabase);
|
||||
entityBuilder.Drop();
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Interfaces;
|
||||
using Oqtane.Migrations;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
@ -16,7 +17,7 @@ namespace Oqtane.Modules.HtmlText.Migrations.EntityBuilders
|
||||
private readonly PrimaryKey<HtmlTextEntityBuilder> _primaryKey = new("PK_HtmlText", x => x.HtmlTextId);
|
||||
private readonly ForeignKey<HtmlTextEntityBuilder> _moduleForeignKey = new("FK_HtmlText_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.Cascade);
|
||||
|
||||
public HtmlTextEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||
public HtmlTextEntityBuilder(MigrationBuilder migrationBuilder, IOqtaneDatabase database) : base(migrationBuilder, database)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
@ -25,7 +26,7 @@ namespace Oqtane.Modules.HtmlText.Migrations.EntityBuilders
|
||||
|
||||
protected override HtmlTextEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
HtmlTextId = table.AddAutoIncrementColumn("HtmlTextId");
|
||||
HtmlTextId = ActiveDatabase.AddAutoIncrementColumn(table,"HtmlTextId");
|
||||
ModuleId = table.AddIntegerColumn("ModuleId");
|
||||
Content = table.AddMaxStringColumn("Content");
|
||||
|
||||
|
Reference in New Issue
Block a user