Added support for migrating existing Oqtane installations from DbUp to Migrations. Also added a Migration for version 2.0.2, and set current version to 2.1.0

This commit is contained in:
Charles Nurse
2021-04-08 12:20:21 -07:00
parent d12b18350f
commit 8c45b7e42f
11 changed files with 331 additions and 80 deletions

View File

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
using Oqtane.Interfaces;
namespace Oqtane.Migrations.EntityBuilders
{
public class AppVersionsEntityBuilder : BaseEntityBuilder<AppVersionsEntityBuilder>
{
private const string _entityTableName = "AppVersions";
private readonly PrimaryKey<AppVersionsEntityBuilder> _primaryKey = new("PK_AppVersions", x => x.Id);
public AppVersionsEntityBuilder(MigrationBuilder migrationBuilder, IOqtaneDatabase database) : base(migrationBuilder, database)
{
EntityTableName = _entityTableName;
PrimaryKey = _primaryKey;
}
protected override AppVersionsEntityBuilder BuildTable(ColumnsBuilder table)
{
Id = AddAutoIncrementColumn(table,"Id");
Version = AddStringColumn(table,"Version", 10);
AppliedDate = AddDateTimeColumn(table,"AppliedDate");
return this;
}
public OperationBuilder<AddColumnOperation> Id { get; set; }
public OperationBuilder<AddColumnOperation> Version { get; set; }
public OperationBuilder<AddColumnOperation> AppliedDate { get; set; }
}
}

View File

@ -83,29 +83,29 @@ namespace Oqtane.Migrations.EntityBuilders
return table.Column<int>(name: RewriteName(name), nullable: nullable);
}
public void AddMaxStringColumn(string name, int length, bool nullable = false)
public void AddMaxStringColumn(string name, int length, bool nullable = false, bool unicode = true)
{
_migrationBuilder.AddColumn<string>(RewriteName(name), RewriteName(EntityTableName), nullable: nullable, unicode: true);
_migrationBuilder.AddColumn<string>(RewriteName(name), RewriteName(EntityTableName), nullable: nullable, unicode: unicode);
}
protected OperationBuilder<AddColumnOperation> AddMaxStringColumn(ColumnsBuilder table, string name, bool nullable = false)
protected OperationBuilder<AddColumnOperation> AddMaxStringColumn(ColumnsBuilder table, string name, bool nullable = false, bool unicode = true)
{
return table.Column<string>(name: RewriteName(name), nullable: nullable, unicode: true);
return table.Column<string>(name: RewriteName(name), nullable: nullable, unicode: unicode);
}
public void AddStringColumn(string name, int length, bool nullable = false)
public void AddStringColumn(string name, int length, bool nullable = false, bool unicode = true)
{
_migrationBuilder.AddColumn<string>(RewriteName(name), RewriteName(EntityTableName), maxLength: length, nullable: nullable, unicode: true);
_migrationBuilder.AddColumn<string>(RewriteName(name), RewriteName(EntityTableName), maxLength: length, nullable: nullable, unicode: unicode);
}
protected OperationBuilder<AddColumnOperation> AddStringColumn(ColumnsBuilder table, string name, int length, bool nullable = false)
protected OperationBuilder<AddColumnOperation> AddStringColumn(ColumnsBuilder table, string name, int length, bool nullable = false, bool unicode = true)
{
return table.Column<string>(name: RewriteName(name), maxLength: length, nullable: nullable, unicode: true);
return table.Column<string>(name: RewriteName(name), maxLength: length, nullable: nullable, unicode: unicode);
}
public void AlterStringColumn(string name, int length, bool nullable = false)
public void AlterStringColumn(string name, int length, bool nullable = false, bool unicode = true)
{
_migrationBuilder.AlterColumn<string>(RewriteName(name), RewriteName(EntityTableName), maxLength: length, nullable: nullable);
_migrationBuilder.AlterColumn<string>(RewriteName(name), RewriteName(EntityTableName), maxLength: length, nullable: nullable, unicode: unicode);
}
public void DropColumn(string name)