Updated the Installation of Oqtane to use Migrations
This commit is contained in:
@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Oqtane.Modules.HtmlText.Migrations.EntityBuilders;
|
||||
using Oqtane.Modules.HtmlText.Repository;
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Migrations
|
||||
{
|
||||
[DbContext(typeof(HtmlTextContext))]
|
||||
[Migration("HtmlText.01.00.00.00")]
|
||||
public class InitializeModule : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
//Create HtmlText table
|
||||
var entityBuilder = new HtmlTextEntityBuilder(migrationBuilder);
|
||||
entityBuilder.Create();
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
//Drop HtmlText table
|
||||
var entityBuilder = new HtmlTextEntityBuilder(migrationBuilder);
|
||||
entityBuilder.Drop();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||
using Oqtane.Migrations;
|
||||
using Oqtane.Migrations.EntityBuilders;
|
||||
using Oqtane.Migrations.Extensions;
|
||||
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Migrations.EntityBuilders
|
||||
{
|
||||
public class HtmlTextEntityBuilder : AuditableBaseEntityBuilder<HtmlTextEntityBuilder>
|
||||
{
|
||||
private const string _entityTableName = "HtmlText";
|
||||
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)
|
||||
{
|
||||
EntityTableName = _entityTableName;
|
||||
PrimaryKey = _primaryKey;
|
||||
ForeignKeys.Add(_moduleForeignKey);
|
||||
}
|
||||
|
||||
protected override HtmlTextEntityBuilder BuildTable(ColumnsBuilder table)
|
||||
{
|
||||
HtmlTextId = table.AddAutoIncrementColumn("HtmlTextId");
|
||||
ModuleId = table.AddIntegerColumn("ModuleId");
|
||||
Content = table.AddMaxStringColumn("Content");
|
||||
|
||||
AddAuditableColumns(table);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public OperationBuilder<AddColumnOperation> HtmlTextId { get; set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
||||
|
||||
public OperationBuilder<AddColumnOperation> Content { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user