Creation of EF Core Migrations - these execute using EF Tools, but are not integrated to run programmatically
This commit is contained in:
parent
c64f350f36
commit
83e5502111
|
@ -28,11 +28,11 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.4" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.4" />
|
||||||
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
|
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Oqtane.Extensions
|
||||||
public static DbContextOptionsBuilder UseOqtaneDatabase([NotNull] this DbContextOptionsBuilder optionsBuilder, string connectionString)
|
public static DbContextOptionsBuilder UseOqtaneDatabase([NotNull] this DbContextOptionsBuilder optionsBuilder, string connectionString)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(connectionString);
|
optionsBuilder.UseSqlServer(connectionString);
|
||||||
|
//optionsBuilder.UseSqlite("Data Source=Oqtane.db");
|
||||||
|
|
||||||
return optionsBuilder;
|
return optionsBuilder;
|
||||||
}
|
}
|
||||||
|
|
60
Oqtane.Server/Migrations/01000000_InitializeMaster.cs
Normal file
60
Oqtane.Server/Migrations/01000000_InitializeMaster.cs
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(MasterDBContext))]
|
||||||
|
[Migration("Master.01.00.00.00")]
|
||||||
|
public class InitializeMaster : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Create Tenant table
|
||||||
|
var tenantEntityBuilder = new TenantEntityBuilder(migrationBuilder);
|
||||||
|
tenantEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create Alias table
|
||||||
|
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder);
|
||||||
|
aliasEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create ModuleDefinitions Table
|
||||||
|
var moduleDefinitionsEntityBuilder = new ModuleDefinitionsEntityBuilder(migrationBuilder);
|
||||||
|
moduleDefinitionsEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create Job Table
|
||||||
|
var jobEntityBuilder = new JobEntityBuilder(migrationBuilder);
|
||||||
|
jobEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create JobLog Table
|
||||||
|
var jobLogEntityBuilder = new JobLogEntityBuilder(migrationBuilder);
|
||||||
|
jobLogEntityBuilder.Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop Alias table
|
||||||
|
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder);
|
||||||
|
aliasEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop JobLog Table
|
||||||
|
var jobLogEntityBuilder = new JobLogEntityBuilder(migrationBuilder);
|
||||||
|
jobLogEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Tenant table
|
||||||
|
var tenantEntityBuilder = new TenantEntityBuilder(migrationBuilder);
|
||||||
|
tenantEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop ModuleDefinitions Table
|
||||||
|
var moduleDefinitionsEntityBuilder = new ModuleDefinitionsEntityBuilder(migrationBuilder);
|
||||||
|
moduleDefinitionsEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Job Table
|
||||||
|
var jobEntityBuilder = new JobEntityBuilder(migrationBuilder);
|
||||||
|
jobEntityBuilder.Drop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
157
Oqtane.Server/Migrations/01000000_InitializeTenant.cs
Normal file
157
Oqtane.Server/Migrations/01000000_InitializeTenant.cs
Normal file
|
@ -0,0 +1,157 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.01.00.00.00")]
|
||||||
|
public class InitializeTenant : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Create Site table
|
||||||
|
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
|
||||||
|
siteEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create Page table
|
||||||
|
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
|
||||||
|
pageEntityBuilder.Create();
|
||||||
|
pageEntityBuilder.AddIndex("IX_Page", new [] {"SiteId", "Path", "UserId"}, true);
|
||||||
|
|
||||||
|
//Create Module table
|
||||||
|
var moduleEntityBuilder = new ModuleEntityBuilder(migrationBuilder);
|
||||||
|
moduleEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create PageModule table
|
||||||
|
var pageModuleEntityBuilder = new PageModuleEntityBuilder(migrationBuilder);
|
||||||
|
pageModuleEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create User table
|
||||||
|
var userEntityBuilder = new UserEntityBuilder(migrationBuilder);
|
||||||
|
userEntityBuilder.Create();
|
||||||
|
userEntityBuilder.AddIndex("IX_User", "Username", true);
|
||||||
|
|
||||||
|
//Create Role table
|
||||||
|
var roleEntityBuilder = new RoleEntityBuilder(migrationBuilder);
|
||||||
|
roleEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create UserRole table
|
||||||
|
var userRoleEntityBuilder = new UserRoleEntityBuilder(migrationBuilder);
|
||||||
|
userRoleEntityBuilder.Create();
|
||||||
|
userRoleEntityBuilder.AddIndex("IX_UserRole", new [] {"RoleId", "UserId"}, true);
|
||||||
|
|
||||||
|
//Create Permission table
|
||||||
|
var permissionEntityBuilder = new PermissionEntityBuilder(migrationBuilder);
|
||||||
|
permissionEntityBuilder.Create();
|
||||||
|
permissionEntityBuilder.AddIndex("IX_Permission", new [] {"SiteId", "EntityName", "EntityId", "PermissionName", "RoleId", "UserId"}, true);
|
||||||
|
|
||||||
|
//Create Setting table
|
||||||
|
var settingEntityBuilder = new SettingEntityBuilder(migrationBuilder);
|
||||||
|
settingEntityBuilder.Create();
|
||||||
|
settingEntityBuilder.AddIndex("IX_Setting", new [] {"EntityName", "EntityId", "SettingName"}, true);
|
||||||
|
|
||||||
|
//Create Profile table
|
||||||
|
var profileEntityBuilder = new ProfileEntityBuilder(migrationBuilder);
|
||||||
|
profileEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create Log table
|
||||||
|
var logEntityBuilder = new LogEntityBuilder(migrationBuilder);
|
||||||
|
logEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create Notification table
|
||||||
|
var notificationEntityBuilder = new NotificationEntityBuilder(migrationBuilder);
|
||||||
|
notificationEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create Folder table
|
||||||
|
var folderEntityBuilder = new FolderEntityBuilder(migrationBuilder);
|
||||||
|
folderEntityBuilder.Create();
|
||||||
|
folderEntityBuilder.AddIndex("IX_Folder", new [] {"SiteId", "Path"}, true);
|
||||||
|
|
||||||
|
//Create File table
|
||||||
|
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder);
|
||||||
|
fileEntityBuilder.Create();
|
||||||
|
|
||||||
|
//Create AspNetUsers table
|
||||||
|
var aspNetUsersEntityBuilder = new AspNetUsersEntityBuilder(migrationBuilder);
|
||||||
|
aspNetUsersEntityBuilder.Create();
|
||||||
|
aspNetUsersEntityBuilder.AddIndex("EmailIndex", "NormalizedEmail", true);
|
||||||
|
aspNetUsersEntityBuilder.AddIndex("UserNameIndex", "NormalizedUserName", true);
|
||||||
|
|
||||||
|
//Create AspNetUserClaims table
|
||||||
|
var aspNetUserClaimsEntityBuilder = new AspNetUserClaimsEntityBuilder(migrationBuilder);
|
||||||
|
aspNetUserClaimsEntityBuilder.Create();
|
||||||
|
aspNetUserClaimsEntityBuilder.AddIndex("IX_AspNetUserClaims_UserId", "UserId", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop AspNetUserClaims table
|
||||||
|
var aspNetUserClaimsEntityBuilder = new AspNetUserClaimsEntityBuilder(migrationBuilder);
|
||||||
|
aspNetUserClaimsEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop AspNetUsers table
|
||||||
|
var aspNetUsersEntityBuilder = new AspNetUsersEntityBuilder(migrationBuilder);
|
||||||
|
aspNetUsersEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop File table
|
||||||
|
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder);
|
||||||
|
fileEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Folder table
|
||||||
|
var folderEntityBuilder = new FolderEntityBuilder(migrationBuilder);
|
||||||
|
folderEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Notification table
|
||||||
|
var notificationEntityBuilder = new NotificationEntityBuilder(migrationBuilder);
|
||||||
|
notificationEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Log table
|
||||||
|
var logEntityBuilder = new LogEntityBuilder(migrationBuilder);
|
||||||
|
logEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Profile table
|
||||||
|
var profileEntityBuilder = new ProfileEntityBuilder(migrationBuilder);
|
||||||
|
profileEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Setting table
|
||||||
|
var settingEntityBuilder = new SettingEntityBuilder(migrationBuilder);
|
||||||
|
settingEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Permission table
|
||||||
|
var permissionEntityBuilder = new PermissionEntityBuilder(migrationBuilder);
|
||||||
|
permissionEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop UserRole table
|
||||||
|
var userRoleEntityBuilder = new UserRoleEntityBuilder(migrationBuilder);
|
||||||
|
userRoleEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Role table
|
||||||
|
var roleEntityBuilder = new RoleEntityBuilder(migrationBuilder);
|
||||||
|
roleEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop User table
|
||||||
|
var userEntityBuilder = new UserEntityBuilder(migrationBuilder);
|
||||||
|
userEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop PageModule table
|
||||||
|
var pageModuleEntityBuilder = new PageModuleEntityBuilder(migrationBuilder);
|
||||||
|
pageModuleEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Module table
|
||||||
|
var moduleEntityBuilder = new ModuleEntityBuilder(migrationBuilder);
|
||||||
|
moduleEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Page table
|
||||||
|
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
|
||||||
|
pageEntityBuilder.Drop();
|
||||||
|
|
||||||
|
//Drop Site table
|
||||||
|
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
|
||||||
|
siteEntityBuilder.Drop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(MasterDBContext))]
|
||||||
|
[Migration("Master.01.00.01.00")]
|
||||||
|
public class AddAdditionalIndexesInMaster : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Update Tenant table
|
||||||
|
var tenantEntityBuilder = new TenantEntityBuilder(migrationBuilder);
|
||||||
|
tenantEntityBuilder.AddIndex("IX_Tenant", "Name");
|
||||||
|
|
||||||
|
//Update Alias table
|
||||||
|
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder);
|
||||||
|
aliasEntityBuilder.AddIndex("IX_Alias", "Name");
|
||||||
|
|
||||||
|
//Update ModuleDefinitions Table
|
||||||
|
var moduleDefinitionsEntityBuilder = new ModuleDefinitionsEntityBuilder(migrationBuilder);
|
||||||
|
moduleDefinitionsEntityBuilder.AddIndex("IX_ModuleDefinition", "ModuleDefinitionName");
|
||||||
|
|
||||||
|
//Update Job Table
|
||||||
|
var jobEntityBuilder = new JobEntityBuilder(migrationBuilder);
|
||||||
|
jobEntityBuilder.AddIndex("IX_Job", "JobType");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Update Tenant table
|
||||||
|
var tenantEntityBuilder = new TenantEntityBuilder(migrationBuilder);
|
||||||
|
tenantEntityBuilder.DropIndex("IX_Tenant");
|
||||||
|
|
||||||
|
//Update Alias table
|
||||||
|
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder);
|
||||||
|
aliasEntityBuilder.DropIndex("IX_Alias");
|
||||||
|
|
||||||
|
//Update ModuleDefinitions Table
|
||||||
|
var moduleDefinitionsEntityBuilder = new ModuleDefinitionsEntityBuilder(migrationBuilder);
|
||||||
|
moduleDefinitionsEntityBuilder.DropIndex("IX_ModuleDefinition");
|
||||||
|
|
||||||
|
//Update Job Table
|
||||||
|
var jobEntityBuilder = new JobEntityBuilder(migrationBuilder);
|
||||||
|
jobEntityBuilder.DropIndex("IX_Job");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.01.00.01.00")]
|
||||||
|
public class AddAdditionalIndexesInTenant : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Create Index on Site
|
||||||
|
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
|
||||||
|
siteEntityBuilder.AddIndex("IX_Site", new [] {"TenantId", "Name"}, true);
|
||||||
|
|
||||||
|
//Create Index on Role table
|
||||||
|
var roleEntityBuilder = new RoleEntityBuilder(migrationBuilder);
|
||||||
|
roleEntityBuilder.AddIndex("IX_Role", new [] {"SiteId", "Name"}, true);
|
||||||
|
|
||||||
|
//Create Index on Profile table
|
||||||
|
var profileEntityBuilder = new ProfileEntityBuilder(migrationBuilder);
|
||||||
|
profileEntityBuilder.AddIndex("IX_Profile", new [] {"SiteId", "Name"}, true);
|
||||||
|
|
||||||
|
//Create Index on File table
|
||||||
|
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder);
|
||||||
|
fileEntityBuilder.AddIndex("IX_File", new [] {"FolderId", "Name"}, true);
|
||||||
|
|
||||||
|
//Add Columns to Notification table
|
||||||
|
var notificationEntityBuilder = new NotificationEntityBuilder(migrationBuilder);
|
||||||
|
notificationEntityBuilder.AddStringColumn("FromDisplayName", 50, true);
|
||||||
|
notificationEntityBuilder.AddStringColumn("FromEmail", 256, true);
|
||||||
|
notificationEntityBuilder.AddStringColumn("ToDisplayName", 50, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop Index on Site table
|
||||||
|
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
|
||||||
|
siteEntityBuilder.DropIndex("IX_Site");
|
||||||
|
|
||||||
|
//Drop Index on Role table
|
||||||
|
var roleEntityBuilder = new RoleEntityBuilder(migrationBuilder);
|
||||||
|
roleEntityBuilder.DropIndex("IX_Role");
|
||||||
|
|
||||||
|
//Drop Index on Profile table
|
||||||
|
var profileEntityBuilder = new ProfileEntityBuilder(migrationBuilder);
|
||||||
|
profileEntityBuilder.DropIndex("IX_Profile");
|
||||||
|
|
||||||
|
//Drop Index on File table
|
||||||
|
var fileEntityBuilder = new FileEntityBuilder(migrationBuilder);
|
||||||
|
fileEntityBuilder.DropIndex("IX_File");
|
||||||
|
|
||||||
|
//Drop Columns from Notification table
|
||||||
|
var notificationEntityBuilder = new NotificationEntityBuilder(migrationBuilder);
|
||||||
|
notificationEntityBuilder.DropColumn("FromDisplayName");
|
||||||
|
notificationEntityBuilder.DropColumn("FromEmail");
|
||||||
|
notificationEntityBuilder.DropColumn("ToDisplayName");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.01.00.01.01")]
|
||||||
|
public class AddAdditionColumnToNotifications : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Add Column to Notification table
|
||||||
|
var notificationEntityBuilder = new NotificationEntityBuilder(migrationBuilder);
|
||||||
|
notificationEntityBuilder.AddDateTimeColumn("SendOn", true);
|
||||||
|
|
||||||
|
migrationBuilder.Sql(
|
||||||
|
@"
|
||||||
|
UPDATE Notification
|
||||||
|
SET SendOn = CreatedOn
|
||||||
|
WHERE SendOn IS NULL;
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop Column from Notification table
|
||||||
|
var notificationEntityBuilder = new NotificationEntityBuilder(migrationBuilder);
|
||||||
|
notificationEntityBuilder.DropColumn("SendOn");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
Oqtane.Server/Migrations/01000201_DropColumnFromPage.cs
Normal file
29
Oqtane.Server/Migrations/01000201_DropColumnFromPage.cs
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.01.00.02.01")]
|
||||||
|
public class DropColumnFromPage : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop Column from Page table
|
||||||
|
if (migrationBuilder.ActiveProvider != "Microsoft.EntityFrameworkCore.Sqlite")
|
||||||
|
{
|
||||||
|
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
|
||||||
|
pageEntityBuilder.DropColumn("EditMode");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Add Column to Page table
|
||||||
|
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
|
||||||
|
pageEntityBuilder.AddBooleanColumn("EditMode");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.02.00.00.01")]
|
||||||
|
public class AddColumnToProfileAndUpdatePage : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Add Column to Profile table
|
||||||
|
var profileEntityBuilder = new ProfileEntityBuilder(migrationBuilder);
|
||||||
|
profileEntityBuilder.AddStringColumn("Options", 2000, true);
|
||||||
|
|
||||||
|
///Update new field
|
||||||
|
migrationBuilder.Sql(
|
||||||
|
@"
|
||||||
|
UPDATE Profile
|
||||||
|
SET Options = ''
|
||||||
|
");
|
||||||
|
|
||||||
|
//Alter Column in Page table
|
||||||
|
if (migrationBuilder.ActiveProvider != "Microsoft.EntityFrameworkCore.Sqlite")
|
||||||
|
{
|
||||||
|
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
|
||||||
|
pageEntityBuilder.DropIndex("IX_Page");
|
||||||
|
pageEntityBuilder.AlterStringColumn("Path", 256);
|
||||||
|
pageEntityBuilder.AddIndex("IX_Page", new [] {"SiteId", "Path", "UserId"}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop Column from Profile table
|
||||||
|
var profileEntityBuilder = new ProfileEntityBuilder(migrationBuilder);
|
||||||
|
profileEntityBuilder.DropColumn("Options");
|
||||||
|
|
||||||
|
//Alter Column in Page table
|
||||||
|
if (migrationBuilder.ActiveProvider != "Microsoft.EntityFrameworkCore.Sqlite")
|
||||||
|
{
|
||||||
|
var pageEntityBuilder = new PageEntityBuilder(migrationBuilder);
|
||||||
|
pageEntityBuilder.DropIndex("IX_Page");
|
||||||
|
pageEntityBuilder.AlterStringColumn("Path", 50);
|
||||||
|
pageEntityBuilder.AddIndex("IX_Page", new [] {"SiteId", "Path", "UserId"}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
Oqtane.Server/Migrations/02000101_UpdateIconColumnInPage.cs
Normal file
21
Oqtane.Server/Migrations/02000101_UpdateIconColumnInPage.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.02.00.01.01")]
|
||||||
|
public class UpdateIconColumnInPage : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
///Update Icon Field in Page
|
||||||
|
migrationBuilder.Sql(
|
||||||
|
@"
|
||||||
|
UPDATE [Page]
|
||||||
|
SET Icon = IIF(Icon <> '', 'oi oi-' + Icon, '');
|
||||||
|
");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
Oqtane.Server/Migrations/02000102_AddLanguageTable.cs
Normal file
26
Oqtane.Server/Migrations/02000102_AddLanguageTable.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.02.00.01.02")]
|
||||||
|
public class AddLanguageTable : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Create Language table
|
||||||
|
var languageEntityBuilder = new LanguageEntityBuilder(migrationBuilder);
|
||||||
|
languageEntityBuilder.Create();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop Language table
|
||||||
|
var languageEntityBuilder = new LanguageEntityBuilder(migrationBuilder);
|
||||||
|
languageEntityBuilder.Drop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(TenantDBContext))]
|
||||||
|
[Migration("Tenant.02.00.01.03")]
|
||||||
|
public class UpdatePageAndAddColumnToSite : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Add Column to Site table
|
||||||
|
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
|
||||||
|
siteEntityBuilder.AddStringColumn("AdminContainerType", 200, true);
|
||||||
|
|
||||||
|
//Update new column
|
||||||
|
migrationBuilder.Sql(
|
||||||
|
@"
|
||||||
|
UPDATE Site
|
||||||
|
SET AdminContainerType = ''
|
||||||
|
");
|
||||||
|
|
||||||
|
//Delete records from Page
|
||||||
|
migrationBuilder.Sql(
|
||||||
|
@"
|
||||||
|
DELETE FROM [Page]
|
||||||
|
WHERE Path = 'admin/tenants';
|
||||||
|
");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Drop Column from Site table
|
||||||
|
var siteEntityBuilder = new SiteEntityBuilder(migrationBuilder);
|
||||||
|
siteEntityBuilder.DropColumn("AdminContainerType");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
using Oqtane.Repository;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(MasterDBContext))]
|
||||||
|
[Migration("Master.02.01.00.00")]
|
||||||
|
public class AddIndexesForForeignKeyInMaster : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Update JobLog table
|
||||||
|
var jobLogEntityBuilder = new JobLogEntityBuilder(migrationBuilder);
|
||||||
|
jobLogEntityBuilder.AddIndex("IX_JobLog_JobId", "JobId");
|
||||||
|
|
||||||
|
//Update Alias table
|
||||||
|
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder);
|
||||||
|
aliasEntityBuilder.AddIndex("IX_Alias_TenantId", "TenantId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Update JobLog table
|
||||||
|
var jobLogEntityBuilder = new JobLogEntityBuilder(migrationBuilder);
|
||||||
|
jobLogEntityBuilder.DropIndex("IX_JobLog_JobId");
|
||||||
|
|
||||||
|
//Update Alias table
|
||||||
|
var aliasEntityBuilder = new AliasEntityBuilder(migrationBuilder);
|
||||||
|
aliasEntityBuilder.DropIndex("IX_Alias_TenantId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class AliasEntityBuilder : AuditableBaseEntityBuilder<AliasEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Alias";
|
||||||
|
private readonly PrimaryKey<AliasEntityBuilder> _primaryKey = new("PK_Alias", x => x.AliasId);
|
||||||
|
private readonly ForeignKey<AliasEntityBuilder> _tenantForeignKey = new("FK_Alias_Tenant", x => x.TenantId, "Tenant", "TenantId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public AliasEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_tenantForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override AliasEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
AliasId = table.AddAutoIncrementColumn("AliasId");
|
||||||
|
Name = table.AddStringColumn("Name", 200);
|
||||||
|
TenantId = table.AddIntegerColumn("TenantId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> AliasId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> TenantId { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class AspNetUserClaimsEntityBuilder : BaseEntityBuilder<AspNetUserClaimsEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "AspNetUserClaims";
|
||||||
|
private readonly PrimaryKey<AspNetUserClaimsEntityBuilder> _primaryKey = new("PK_AspNetUserClaims", x => x.Id);
|
||||||
|
private readonly ForeignKey<AspNetUserClaimsEntityBuilder> _aspNetUsersForeignKey = new("FK_AspNetUserClaims_AspNetUsers_UserId", x => x.UserId, "AspNetUsers", "Id", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public AspNetUserClaimsEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_aspNetUsersForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override AspNetUserClaimsEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
Id = table.AddAutoIncrementColumn("Id");
|
||||||
|
UserId = table.AddStringColumn("UserId", 450);
|
||||||
|
ClaimType = table.AddMaxStringColumn("ClaimType", true);
|
||||||
|
ClaimValue = table.AddMaxStringColumn("ClaimValue", true);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Id { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ClaimType { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ClaimValue { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class AspNetUsersEntityBuilder : BaseEntityBuilder<AspNetUsersEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "AspNetUsers";
|
||||||
|
private readonly PrimaryKey<AspNetUsersEntityBuilder> _primaryKey = new("PK_AspNetUsers", x => x.Id);
|
||||||
|
|
||||||
|
public AspNetUsersEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override AspNetUsersEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
Id = table.AddStringColumn("Id", 450);
|
||||||
|
UserName = table.AddStringColumn("Username", 256, true);
|
||||||
|
NormalizedUserName = table.AddStringColumn("NormalizedUserName", 256, true);
|
||||||
|
Email = table.AddStringColumn("Email", 256, true);
|
||||||
|
NormalizedEmail = table.AddStringColumn("NormalizedEmail", 256, true);
|
||||||
|
EmailConfirmed = table.AddBooleanColumn("EmailConfirmed");
|
||||||
|
PasswordHash = table.AddMaxStringColumn("PasswordHash", true);
|
||||||
|
SecurityStamp = table.AddMaxStringColumn("SecurityStamp", true);
|
||||||
|
ConcurrencyStamp = table.AddMaxStringColumn("ConcurrencyStamp", true);
|
||||||
|
PhoneNumber = table.AddMaxStringColumn("PhoneNumber", true);
|
||||||
|
PhoneNumberConfirmed = table.AddBooleanColumn("PhoneNumberConfirmed");
|
||||||
|
TwoFactorEnabled = table.AddBooleanColumn("TwoFactorEnabled");
|
||||||
|
LockoutEnd = table.AddDateTimeOffsetColumn("LockoutEnd", true);
|
||||||
|
LockoutEnabled = table.AddBooleanColumn("LockoutEnabled");
|
||||||
|
AccessFailedCount = table.AddIntegerColumn("AccessFailedCount");
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Id { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserName { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> NormalizedUserName { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Email { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> NormalizedEmail { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EmailConfirmed { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PasswordHash { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SecurityStamp { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ConcurrencyStamp { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PhoneNumber { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PhoneNumberConfirmed { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> TwoFactorEnabled { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LockoutEnd { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LockoutEnabled { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> AccessFailedCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public abstract class AuditableBaseEntityBuilder<TEntityBuilder> : BaseEntityBuilder<TEntityBuilder> where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
protected AuditableBaseEntityBuilder(MigrationBuilder migrationBuilder) : base (migrationBuilder)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AddAuditableColumns(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
CreatedBy = table.AddStringColumn("CreatedBy", 256);
|
||||||
|
CreatedOn = table.AddDateTimeColumn("CreatedOn");
|
||||||
|
ModifiedBy = table.AddStringColumn("ModifiedBy", 256);
|
||||||
|
ModifiedOn = table.AddDateTimeColumn("ModifiedOn");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> CreatedBy { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> CreatedOn { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModifiedBy { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModifiedOn { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
118
Oqtane.Server/Migrations/EntityBuilders/BaseEntityBuilder.cs
Normal file
118
Oqtane.Server/Migrations/EntityBuilders/BaseEntityBuilder.cs
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public abstract class BaseEntityBuilder<TEntityBuilder> where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
private readonly MigrationBuilder _migrationBuilder;
|
||||||
|
|
||||||
|
protected BaseEntityBuilder(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
_migrationBuilder = migrationBuilder;
|
||||||
|
ForeignKeys = new List<ForeignKey<TEntityBuilder>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddKeys(CreateTableBuilder<TEntityBuilder> table)
|
||||||
|
{
|
||||||
|
table.AddPrimaryKey(PrimaryKey);
|
||||||
|
foreach (var foreignKey in ForeignKeys)
|
||||||
|
{
|
||||||
|
table.AddForeignKey(foreignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract TEntityBuilder BuildTable(ColumnsBuilder table);
|
||||||
|
|
||||||
|
protected string EntityTableName { get; init; }
|
||||||
|
|
||||||
|
protected PrimaryKey<TEntityBuilder> PrimaryKey { get; init; }
|
||||||
|
|
||||||
|
protected List<ForeignKey<TEntityBuilder>> ForeignKeys { get; }
|
||||||
|
|
||||||
|
public void AddBooleanColumn(string name)
|
||||||
|
{
|
||||||
|
_migrationBuilder.AddColumn<bool>(name, EntityTableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddDateTimeColumn(string name, bool nullable = false)
|
||||||
|
{
|
||||||
|
_migrationBuilder.AddColumn<DateTime>(name, EntityTableName, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a Migration to add an Index to the Entity (table)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="indexName">The name of the Index to create</param>
|
||||||
|
/// <param name="columnName">The name of the column to add to the index</param>
|
||||||
|
/// <param name="isUnique">A flag that determines if the Index should be Unique</param>
|
||||||
|
public virtual void AddIndex(string indexName, string columnName, bool isUnique = false)
|
||||||
|
{
|
||||||
|
_migrationBuilder.CreateIndex(
|
||||||
|
name: indexName,
|
||||||
|
table: EntityTableName,
|
||||||
|
column: columnName,
|
||||||
|
unique: isUnique);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a Migration to add an Index to the Entity (table)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="indexName">The name of the Index to create</param>
|
||||||
|
/// <param name="columnName">The names of the columns to add to the index</param>
|
||||||
|
/// <param name="isUnique">A flag that determines if the Index should be Unique</param>
|
||||||
|
public virtual void AddIndex(string indexName, string[] columnNames, bool isUnique = false)
|
||||||
|
{
|
||||||
|
_migrationBuilder.CreateIndex(
|
||||||
|
name: indexName,
|
||||||
|
table: EntityTableName,
|
||||||
|
columns: columnNames,
|
||||||
|
unique: isUnique);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddStringColumn(string name, int length, bool nullable = false)
|
||||||
|
{
|
||||||
|
_migrationBuilder.AddColumn<string>(name, EntityTableName, maxLength: length, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AlterStringColumn(string name, int length, bool nullable = false)
|
||||||
|
{
|
||||||
|
_migrationBuilder.AlterColumn<string>(name, EntityTableName, maxLength: length, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a Migration to Create the Entity (table)
|
||||||
|
/// </summary>
|
||||||
|
public void Create()
|
||||||
|
{
|
||||||
|
_migrationBuilder.CreateTable(EntityTableName, BuildTable, null, AddKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a Migration to Drop the Entity (table)
|
||||||
|
/// </summary>
|
||||||
|
public void Drop()
|
||||||
|
{
|
||||||
|
_migrationBuilder.DropTable(EntityTableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DropColumn(string name)
|
||||||
|
{
|
||||||
|
_migrationBuilder.DropColumn(name, EntityTableName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a Migration to drop an Index from the Entity (table)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="indexName">The name of the Index to drop</param>
|
||||||
|
public virtual void DropIndex(string indexName)
|
||||||
|
{
|
||||||
|
_migrationBuilder.DropIndex(indexName, EntityTableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public abstract class DeletableAuditableBaseEntityBuilder<TEntityBuilder> : AuditableBaseEntityBuilder<TEntityBuilder> where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
protected DeletableAuditableBaseEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AddDeletableColumns(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
DeletedBy = table.AddStringColumn("DeletedBy", 256, true);
|
||||||
|
DeletedOn = table.AddDateTimeColumn("DeletedOn", true);
|
||||||
|
IsDeleted = table.AddBooleanColumn("IsDeleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DeletedBy { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DeletedOn { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsDeleted { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public abstract class DeletableBaseEntityBuilder<TEntityBuilder> : BaseEntityBuilder<TEntityBuilder> where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
protected DeletableBaseEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void AddDeletableColumns(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
DeletedBy = table.AddStringColumn("DeletedBy", 256, true);
|
||||||
|
DeletedOn = table.AddDateTimeColumn("DeletedOn", true);
|
||||||
|
IsDeleted = table.AddBooleanColumn("IsDeleted");
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DeletedBy { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DeletedOn { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsDeleted { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
54
Oqtane.Server/Migrations/EntityBuilders/FileEntityBuilder.cs
Normal file
54
Oqtane.Server/Migrations/EntityBuilders/FileEntityBuilder.cs
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class FileEntityBuilder : DeletableAuditableBaseEntityBuilder<FileEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "File";
|
||||||
|
private readonly PrimaryKey<FileEntityBuilder> _primaryKey = new("PK_File", x => x.FileId);
|
||||||
|
private readonly ForeignKey<FileEntityBuilder> _folderForeignKey = new("FK_File_Folder", x => x.FolderId, "Folder", "FolderId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public FileEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_folderForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override FileEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
FileId = table.AddAutoIncrementColumn("FileId");
|
||||||
|
FolderId = table.AddIntegerColumn("FolderId");
|
||||||
|
Name = table.AddStringColumn("Name", 50);
|
||||||
|
Extension = table.AddStringColumn("Extension", 50);
|
||||||
|
Size = table.AddIntegerColumn("Size");
|
||||||
|
ImageHeight = table.AddIntegerColumn("ImageHeight");
|
||||||
|
ImageWidth = table.AddIntegerColumn("ImageWidth");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
AddDeletableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> FileId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> FolderId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Extension { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Size { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ImageHeight { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ImageWidth { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class FolderEntityBuilder : DeletableAuditableBaseEntityBuilder<FolderEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Folder";
|
||||||
|
private readonly PrimaryKey<FolderEntityBuilder> _primaryKey = new("PK_Folder", x => x.FolderId);
|
||||||
|
private readonly ForeignKey<FolderEntityBuilder> _siteForeignKey = new("FK_Folder_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public FolderEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override FolderEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
FolderId = table.AddAutoIncrementColumn("FolderId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId");
|
||||||
|
ParentId = table.AddIntegerColumn("ParentId", true);
|
||||||
|
Name = table.AddStringColumn("Name", 50);
|
||||||
|
Path = table.AddStringColumn("Path", 50);
|
||||||
|
Order = table.AddIntegerColumn("Order");
|
||||||
|
IsSystem = table.AddBooleanColumn("IsSystem");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
AddDeletableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> FolderId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ParentId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Path { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Order { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsSystem { get; set; }
|
||||||
|
}
|
||||||
|
}
|
66
Oqtane.Server/Migrations/EntityBuilders/JobEntityBuilder.cs
Normal file
66
Oqtane.Server/Migrations/EntityBuilders/JobEntityBuilder.cs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class JobEntityBuilder : AuditableBaseEntityBuilder<JobEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Job";
|
||||||
|
private readonly PrimaryKey<JobEntityBuilder> _primaryKey = new("PK_Job", x => x.JobId);
|
||||||
|
|
||||||
|
public JobEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override JobEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
JobId = table.AddAutoIncrementColumn("JobId");
|
||||||
|
Name = table.AddStringColumn("Name", 200);
|
||||||
|
JobType = table.AddStringColumn("JobType", 200);
|
||||||
|
Frequency = table.AddStringColumn("Frequency", 1);
|
||||||
|
Interval = table.AddIntegerColumn("Interval");
|
||||||
|
StartDate = table.AddDateTimeColumn("StartDate", true);
|
||||||
|
EndDate = table.AddDateTimeColumn("EndDate", true);
|
||||||
|
IsEnabled = table.AddBooleanColumn("IsEnabled");
|
||||||
|
IsStarted = table.AddBooleanColumn("IsStarted");
|
||||||
|
IsExecuting = table.AddBooleanColumn("IsExecuting");
|
||||||
|
NextExecution = table.AddDateTimeColumn("NextExecution", true);
|
||||||
|
RetentionHistory = table.AddIntegerColumn("RetentionHistory");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> JobId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> JobType { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Frequency { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Interval { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> StartDate { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EndDate { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsEnabled { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsStarted { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsExecuting { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> NextExecution { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> RetentionHistory { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class JobLogEntityBuilder : BaseEntityBuilder<JobLogEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "JobLog";
|
||||||
|
private readonly PrimaryKey<JobLogEntityBuilder> _primaryKey = new("PK_JobLog", x => x.JobLogId);
|
||||||
|
private readonly ForeignKey<JobLogEntityBuilder> _jobLogForeignKey = new("FK_JobLog_Job", x => x.JobId, "Job", "JobId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public JobLogEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_jobLogForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override JobLogEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
JobLogId = table.AddAutoIncrementColumn("JobLogId");
|
||||||
|
JobId = table.AddIntegerColumn("JobId");
|
||||||
|
StartDate = table.AddDateTimeColumn("StartDate");
|
||||||
|
FinishDate = table.AddDateTimeColumn("FinishDate", true);
|
||||||
|
Succeeded = table.AddBooleanColumn("Succeeded", true);
|
||||||
|
Notes = table.AddMaxStringColumn("Notes", true);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> JobLogId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> JobId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> StartDate { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> FinishDate { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Succeeded { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Notes { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class LanguageEntityBuilder : AuditableBaseEntityBuilder<LanguageEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Language";
|
||||||
|
private readonly PrimaryKey<LanguageEntityBuilder> _primaryKey = new("PK_Language", x => x.LanguageId);
|
||||||
|
private readonly ForeignKey<LanguageEntityBuilder> _siteForeignKey = new("FK_Language_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public LanguageEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override LanguageEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
LanguageId = table.AddAutoIncrementColumn("LanguageId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId");
|
||||||
|
Name = table.AddStringColumn("Name", 100);
|
||||||
|
Code = table.AddStringColumn("Code", 10);
|
||||||
|
IsDefault = table.AddBooleanColumn("IsDefault");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LanguageId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Code { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsDefault { get; set; }
|
||||||
|
}
|
||||||
|
}
|
78
Oqtane.Server/Migrations/EntityBuilders/LogEntityBuilder.cs
Normal file
78
Oqtane.Server/Migrations/EntityBuilders/LogEntityBuilder.cs
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class LogEntityBuilder : BaseEntityBuilder<LogEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Log";
|
||||||
|
private readonly PrimaryKey<LogEntityBuilder> _primaryKey = new("PK_Log", x => x.LogId);
|
||||||
|
private readonly ForeignKey<LogEntityBuilder> _siteForeignKey = new("FK_Log_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public LogEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override LogEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
LogId = table.AddAutoIncrementColumn("LogId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId", true);
|
||||||
|
LogDate = table.AddDateTimeColumn("LogDate");
|
||||||
|
PageId = table.AddIntegerColumn("PageId", true);
|
||||||
|
ModuleId = table.AddIntegerColumn("ModuleId", true);
|
||||||
|
UserId = table.AddIntegerColumn("UserId", true);
|
||||||
|
Url = table.AddStringColumn("Url", 2048);
|
||||||
|
Server = table.AddStringColumn("Server", 200);
|
||||||
|
Category = table.AddStringColumn("Category", 200);
|
||||||
|
Feature = table.AddStringColumn("Feature", 200);
|
||||||
|
Function = table.AddStringColumn("Function", 20);
|
||||||
|
Level = table.AddStringColumn("Level", 20);
|
||||||
|
Message = table.AddMaxStringColumn("Message");
|
||||||
|
MessageTemplate = table.AddMaxStringColumn("MessageTemplate");
|
||||||
|
Exception = table.AddMaxStringColumn("Exception", true);
|
||||||
|
Properties = table.AddMaxStringColumn("Properties", true);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LogId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LogDate { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PageId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModuleId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Url { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Server { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Category { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Feature { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Function { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Level { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Message { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> MessageTemplate { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Exception { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Properties { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class ModuleDefinitionsEntityBuilder : AuditableBaseEntityBuilder<ModuleDefinitionsEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "ModuleDefinition";
|
||||||
|
private readonly PrimaryKey<ModuleDefinitionsEntityBuilder> _primaryKey = new("PK_ModuleDefinition", x => x.ModuleDefinitionId);
|
||||||
|
|
||||||
|
public ModuleDefinitionsEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override ModuleDefinitionsEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
ModuleDefinitionId = table.AddAutoIncrementColumn("ModuleDefinitionId");
|
||||||
|
ModuleDefinitionName = table.AddStringColumn("ModuleDefinitionName", 200);
|
||||||
|
Name = table.AddStringColumn("Name", 200, true);
|
||||||
|
Description = table.AddStringColumn("Description", 2000, true);
|
||||||
|
Categories = table.AddStringColumn("Categories", 200, true);
|
||||||
|
Version = table.AddStringColumn("Version", 50, true);
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModuleDefinitionId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModuleDefinitionName { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Description { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Categories { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Version { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class ModuleEntityBuilder : AuditableBaseEntityBuilder<ModuleEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Module";
|
||||||
|
private readonly PrimaryKey<ModuleEntityBuilder> _primaryKey = new("PK_Module", x => x.ModuleId);
|
||||||
|
private readonly ForeignKey<ModuleEntityBuilder> _siteForeignKey = new("FK_Module_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public ModuleEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override ModuleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
ModuleId = table.AddAutoIncrementColumn("ModuleId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId");
|
||||||
|
ModuleDefinitionName = table.AddStringColumn("ModuleDefinitionName", 200);
|
||||||
|
AllPages = table.AddBooleanColumn("AllPages");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModuleId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModuleDefinitionName { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> AllPages { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class NotificationEntityBuilder : DeletableBaseEntityBuilder<NotificationEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Notification";
|
||||||
|
private readonly PrimaryKey<NotificationEntityBuilder> _primaryKey = new("PK_Notification", x => x.NotificationId);
|
||||||
|
private readonly ForeignKey<NotificationEntityBuilder> _siteForeignKey = new("FK_Notification_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public NotificationEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override NotificationEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
NotificationId = table.AddAutoIncrementColumn("NotificationId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId");
|
||||||
|
FromUserId = table.AddIntegerColumn("FromUserId", true);
|
||||||
|
ToUserId = table.AddIntegerColumn("ToUserId", true);
|
||||||
|
ToEmail = table.AddStringColumn("ToEmail", 256);
|
||||||
|
ParentId = table.AddIntegerColumn("ParentId", true);
|
||||||
|
Subject = table.AddStringColumn("Subject", 256);
|
||||||
|
Body = table.AddMaxStringColumn("Body");
|
||||||
|
CreatedOn = table.AddDateTimeColumn("CreatedOn");
|
||||||
|
IsDelivered = table.AddBooleanColumn("IsDelivered");
|
||||||
|
DeliveredOn = table.AddDateTimeColumn("DeliveredOn", true);
|
||||||
|
|
||||||
|
AddDeletableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> NotificationId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> FromUserId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ToUserId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ToEmail { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ParentId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Subject { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Body { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> CreatedOn { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsDelivered { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DeliveredOn { get; set; }
|
||||||
|
}
|
||||||
|
}
|
80
Oqtane.Server/Migrations/EntityBuilders/PageEntityBuilder.cs
Normal file
80
Oqtane.Server/Migrations/EntityBuilders/PageEntityBuilder.cs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class PageEntityBuilder : DeletableAuditableBaseEntityBuilder<PageEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Page";
|
||||||
|
private readonly PrimaryKey<PageEntityBuilder> _primaryKey = new("PK_Page", x => x.PageId);
|
||||||
|
private readonly ForeignKey<PageEntityBuilder> _siteForeignKey = new("FK_Page_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public PageEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override PageEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
PageId = table.AddAutoIncrementColumn("PageId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId");
|
||||||
|
Path = table.AddStringColumn("Path", 50);
|
||||||
|
Name = table.AddStringColumn("Name", 50);
|
||||||
|
Title = table.AddStringColumn("Title", 200, true);
|
||||||
|
ThemeType = table.AddStringColumn("ThemeType", 200, true);
|
||||||
|
Icon = table.AddStringColumn("Icon", 50);
|
||||||
|
ParentId = table.AddIntegerColumn("ParentId", true);
|
||||||
|
Order = table.AddIntegerColumn("Order");
|
||||||
|
IsNavigation = table.AddBooleanColumn("IsNavigation");
|
||||||
|
Url = table.AddStringColumn("Url", 500, true);
|
||||||
|
LayoutType = table.AddStringColumn("LayoutType", 200);
|
||||||
|
EditMode = table.AddBooleanColumn("EditMode");
|
||||||
|
UserId = table.AddIntegerColumn("UserId", true);
|
||||||
|
IsPersonalizable = table.AddBooleanColumn("IsPersonalizable");
|
||||||
|
DefaultContainerType = table.AddStringColumn("DefaultContainerType", 200, true);
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
AddDeletableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PageId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Path { get; private set; }
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Title { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ThemeType { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Icon { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ParentId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Order { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsNavigation { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Url { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LayoutType { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EditMode { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsPersonalizable { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DefaultContainerType { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class PageModuleEntityBuilder : DeletableAuditableBaseEntityBuilder<PageModuleEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "PageModule";
|
||||||
|
private readonly PrimaryKey<PageModuleEntityBuilder> _primaryKey = new("PK_PageModule", x => x.PageModuleId);
|
||||||
|
private readonly ForeignKey<PageModuleEntityBuilder> _moduleForeignKey = new("FK_PageModule_Module", x => x.ModuleId, "Module", "ModuleId", ReferentialAction.NoAction);
|
||||||
|
private readonly ForeignKey<PageModuleEntityBuilder> _pageForeignKey = new("FK_PageModule_Page", x => x.PageId, "Page", "PageId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public PageModuleEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_moduleForeignKey);
|
||||||
|
ForeignKeys.Add(_pageForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override PageModuleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
PageModuleId = table.AddAutoIncrementColumn("PageModuleId");
|
||||||
|
PageId = table.AddIntegerColumn("PageId");
|
||||||
|
ModuleId = table.AddIntegerColumn("ModuleId");
|
||||||
|
Title = table.AddStringColumn("Title", 200);
|
||||||
|
Pane = table.AddStringColumn("Pane", 50);
|
||||||
|
Order = table.AddIntegerColumn("Order");
|
||||||
|
ContainerType = table.AddStringColumn("ContainerType", 200);
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
AddDeletableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PageModuleId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PageId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ModuleId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Title { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Pane { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Order { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ContainerType { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class PermissionEntityBuilder : AuditableBaseEntityBuilder<PermissionEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Permission";
|
||||||
|
private readonly PrimaryKey<PermissionEntityBuilder> _primaryKey = new("PK_Permission", x => x.PermissionId);
|
||||||
|
private readonly ForeignKey<PermissionEntityBuilder> _siteForeignKey = new("FK_Permission_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
private readonly ForeignKey<PermissionEntityBuilder> _userForeignKey = new("FK_Permission_User", x => x.UserId, "User", "UserId", ReferentialAction.NoAction);
|
||||||
|
private readonly ForeignKey<PermissionEntityBuilder> _roleForeignKey = new("FK_Permission_Role", x => x.RoleId, "Role", "RoleId", ReferentialAction.NoAction);
|
||||||
|
|
||||||
|
public PermissionEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
ForeignKeys.Add(_userForeignKey);
|
||||||
|
ForeignKeys.Add(_roleForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override PermissionEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
PermissionId = table.AddAutoIncrementColumn("PermissionId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId");
|
||||||
|
EntityName = table.AddStringColumn("EntityName", 50);
|
||||||
|
EntityId = table.AddIntegerColumn("EntityId");
|
||||||
|
PermissionName = table.AddStringColumn("PermissionName", 50);
|
||||||
|
RoleId = table.AddIntegerColumn("RoleId", true);
|
||||||
|
UserId = table.AddIntegerColumn("UserId", true);
|
||||||
|
IsAuthorized = table.AddBooleanColumn("IsAuthorized");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PermissionId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EntityName { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EntityId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PermissionName { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> RoleId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsAuthorized { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class ProfileEntityBuilder : AuditableBaseEntityBuilder<ProfileEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Profile";
|
||||||
|
private readonly PrimaryKey<ProfileEntityBuilder> _primaryKey = new("PK_Profile", x => x.ProfileId);
|
||||||
|
private readonly ForeignKey<ProfileEntityBuilder> _siteForeignKey = new("FK_Profile_Sites", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public ProfileEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override ProfileEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
ProfileId = table.AddAutoIncrementColumn("ProfileId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId", true);
|
||||||
|
Name = table.AddStringColumn("Name", 50);
|
||||||
|
Title = table.AddStringColumn("Title", 50);
|
||||||
|
Description = table.AddStringColumn("Description", 256, true);
|
||||||
|
Category = table.AddStringColumn("Category", 50);
|
||||||
|
ViewOrder = table.AddIntegerColumn("ViewOrder");
|
||||||
|
MaxLength = table.AddIntegerColumn("MaxLength");
|
||||||
|
DefaultValue = table.AddStringColumn("DefaultValue", 2000, true);
|
||||||
|
IsRequired = table.AddBooleanColumn("IsRequired");
|
||||||
|
IsPrivate = table.AddBooleanColumn("IsPrivate");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ProfileId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Title { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Description { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Category { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ViewOrder { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> MaxLength { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DefaultValue { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsRequired { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsPrivate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
50
Oqtane.Server/Migrations/EntityBuilders/RoleEntityBuilder.cs
Normal file
50
Oqtane.Server/Migrations/EntityBuilders/RoleEntityBuilder.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class RoleEntityBuilder : AuditableBaseEntityBuilder<RoleEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Role";
|
||||||
|
private readonly PrimaryKey<RoleEntityBuilder> _primaryKey = new("PK_Role", x => x.RoleId);
|
||||||
|
private readonly ForeignKey<RoleEntityBuilder> _siteForeignKey = new("FK_Role_Site", x => x.SiteId, "Site", "SiteId", ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
public RoleEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_siteForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override RoleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
RoleId = table.AddAutoIncrementColumn("RoleId");
|
||||||
|
SiteId = table.AddIntegerColumn("SiteId", true);
|
||||||
|
Name = table.AddStringColumn("Name", 256);
|
||||||
|
Description = table.AddStringColumn("Description", 256);
|
||||||
|
IsAutoAssigned = table.AddBooleanColumn("IsAutoAssigned");
|
||||||
|
IsSystem = table.AddBooleanColumn("IsSystem");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> RoleId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Description { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsAutoAssigned { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> IsSystem { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class SettingEntityBuilder : AuditableBaseEntityBuilder<SettingEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Setting";
|
||||||
|
private readonly PrimaryKey<SettingEntityBuilder> _primaryKey = new("PK_Setting", x => x.SettingId);
|
||||||
|
|
||||||
|
public SettingEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override SettingEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
SettingId = table.AddAutoIncrementColumn("SettingId");
|
||||||
|
EntityName = table.AddStringColumn("EntityName", 50);
|
||||||
|
EntityId = table.AddIntegerColumn("EntityId");
|
||||||
|
SettingName = table.AddStringColumn("SettingName", 50);
|
||||||
|
SettingValue = table.AddMaxStringColumn("SettingValue");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SettingId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EntityName { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EntityId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SettingName { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SettingValue { get; set; }
|
||||||
|
}
|
||||||
|
}
|
67
Oqtane.Server/Migrations/EntityBuilders/SiteEntityBuilder.cs
Normal file
67
Oqtane.Server/Migrations/EntityBuilders/SiteEntityBuilder.cs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class SiteEntityBuilder : DeletableAuditableBaseEntityBuilder<SiteEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Site";
|
||||||
|
private readonly PrimaryKey<SiteEntityBuilder> _primaryKey = new("PK_Site", x => x.SiteId);
|
||||||
|
|
||||||
|
public SiteEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override SiteEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
SiteId = table.AddAutoIncrementColumn("SiteId");
|
||||||
|
TenantId = table.AddIntegerColumn("TenantId");
|
||||||
|
Name = table.AddStringColumn("Name", 200);
|
||||||
|
LogoFileId = table.AddIntegerColumn("LogoFileId", true);
|
||||||
|
FaviconFileId = table.AddIntegerColumn("FaviconFileId", true);
|
||||||
|
DefaultThemeType = table.AddStringColumn("DefaultThemeType", 200);
|
||||||
|
DefaultLayoutType = table.AddStringColumn("DefaultLayoutType", 200);
|
||||||
|
DefaultContainerType = table.AddStringColumn("DefaultContainerType", 200);
|
||||||
|
PwaIsEnabled = table.AddBooleanColumn("PwaIsEnabled");
|
||||||
|
PwaAppIconFileId = table.AddIntegerColumn("PwaAppIconFileId", true);
|
||||||
|
PwaSplashIconFileId = table.AddIntegerColumn("PwaSplashIconFileId", true);
|
||||||
|
AllowRegistration = table.AddBooleanColumn("AllowRegistration");
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
AddDeletableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> SiteId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> TenantId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LogoFileId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> FaviconFileId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DefaultThemeType { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DefaultLayoutType { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DefaultContainerType { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PwaIsEnabled { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PwaAppIconFileId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PwaSplashIconFileId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> AllowRegistration { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class TenantEntityBuilder : AuditableBaseEntityBuilder<TenantEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "Tenant";
|
||||||
|
private readonly PrimaryKey<TenantEntityBuilder> _primaryKey = new("PK_Tenant", x => x.TenantId);
|
||||||
|
|
||||||
|
public TenantEntityBuilder(MigrationBuilder migrationBuilder): base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override TenantEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
TenantId = table.AddAutoIncrementColumn("TenantId");
|
||||||
|
Name = table.AddStringColumn("Name", 100);
|
||||||
|
DBConnectionString = table.AddStringColumn("DBConnectionString", 1024);
|
||||||
|
Version = table.AddStringColumn("Version", 50, true);
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> TenantId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Name { get;private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DBConnectionString { get; private set;}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Version { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
52
Oqtane.Server/Migrations/EntityBuilders/UserEntityBuilder.cs
Normal file
52
Oqtane.Server/Migrations/EntityBuilders/UserEntityBuilder.cs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class UserEntityBuilder : DeletableAuditableBaseEntityBuilder<UserEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "User";
|
||||||
|
private readonly PrimaryKey<UserEntityBuilder> _primaryKey = new("PK_User", x => x.UserId);
|
||||||
|
|
||||||
|
public UserEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override UserEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
UserId = table.AddAutoIncrementColumn("UserId");
|
||||||
|
Username = table.AddStringColumn("Username", 256);
|
||||||
|
DisplayName = table.AddStringColumn("DisplayName", 50);
|
||||||
|
Email = table.AddStringColumn("Email", 256);
|
||||||
|
PhotoFileId = table.AddIntegerColumn("PhotoFileId", true);
|
||||||
|
LastLoginOn = table.AddDateTimeColumn("LastLoginOn", true);
|
||||||
|
LastIPAddress = table.AddStringColumn("LastIpAddress", 50);
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
AddDeletableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Username { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> DisplayName { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> Email { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> PhotoFileId { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LastLoginOn { get; private set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> LastIPAddress { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.Extensions;
|
||||||
|
|
||||||
|
// ReSharper disable MemberCanBePrivate.Global
|
||||||
|
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.EntityBuilders
|
||||||
|
{
|
||||||
|
public class UserRoleEntityBuilder : AuditableBaseEntityBuilder<UserRoleEntityBuilder>
|
||||||
|
{
|
||||||
|
private const string _entityTableName = "UserRole";
|
||||||
|
private readonly PrimaryKey<UserRoleEntityBuilder> _primaryKey = new("PK_UserRole", x => x.UserRoleId);
|
||||||
|
private readonly ForeignKey<UserRoleEntityBuilder> _userForeignKey = new("FK_UserRole_User", x => x.UserId, "User", "UserId", ReferentialAction.Cascade);
|
||||||
|
private readonly ForeignKey<UserRoleEntityBuilder> _roleForeignKey = new("FK_UserRole_Role", x => x.RoleId, "Role", "RoleId", ReferentialAction.NoAction);
|
||||||
|
|
||||||
|
public UserRoleEntityBuilder(MigrationBuilder migrationBuilder) : base(migrationBuilder)
|
||||||
|
{
|
||||||
|
EntityTableName = _entityTableName;
|
||||||
|
PrimaryKey = _primaryKey;
|
||||||
|
ForeignKeys.Add(_userForeignKey);
|
||||||
|
ForeignKeys.Add(_roleForeignKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override UserRoleEntityBuilder BuildTable(ColumnsBuilder table)
|
||||||
|
{
|
||||||
|
UserRoleId = table.AddAutoIncrementColumn("UserRoleId");
|
||||||
|
UserId = table.AddIntegerColumn("UserId");
|
||||||
|
RoleId = table.AddIntegerColumn("RoleId");
|
||||||
|
EffectiveDate = table.AddDateTimeColumn("EffectiveDate", true);
|
||||||
|
ExpiryDate = table.AddDateTimeColumn("ExpiryDate", true);
|
||||||
|
|
||||||
|
AddAuditableColumns(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserRoleId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> UserId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> RoleId { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> EffectiveDate { get; set; }
|
||||||
|
|
||||||
|
public OperationBuilder<AddColumnOperation> ExpiryDate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.Extensions
|
||||||
|
{
|
||||||
|
public static class ColumnsBuilderExtensions
|
||||||
|
{
|
||||||
|
public static OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(this ColumnsBuilder table, string name)
|
||||||
|
{
|
||||||
|
return table.Column<int>(name: name, nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1")
|
||||||
|
.Annotation("Sqlite:Autoincrement", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationBuilder<AddColumnOperation> AddBooleanColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||||
|
{
|
||||||
|
return table.Column<bool>(name: name, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationBuilder<AddColumnOperation> AddDateTimeColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||||
|
{
|
||||||
|
return table.Column<DateTime>(name: name, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationBuilder<AddColumnOperation> AddDateTimeOffsetColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||||
|
{
|
||||||
|
return table.Column<DateTimeOffset>(name: name, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationBuilder<AddColumnOperation> AddIntegerColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||||
|
{
|
||||||
|
return table.Column<int>(name: name, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationBuilder<AddColumnOperation> AddMaxStringColumn(this ColumnsBuilder table, string name, bool nullable = false)
|
||||||
|
{
|
||||||
|
return table.Column<string>(name: name, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationBuilder<AddColumnOperation> AddStringColumn(this ColumnsBuilder table, string name, int length, bool nullable = false)
|
||||||
|
{
|
||||||
|
return table.Column<string>(name: name, maxLength: length, nullable: nullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations.Extensions
|
||||||
|
{
|
||||||
|
public static class CreateTableBuilderExtensions
|
||||||
|
{
|
||||||
|
public static void AddForeignKey<TEntityBuilder>(this CreateTableBuilder<TEntityBuilder> table, ForeignKey<TEntityBuilder> foreignKey) where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
table.ForeignKey(
|
||||||
|
name: foreignKey.Name,
|
||||||
|
column: foreignKey.Column,
|
||||||
|
principalTable: foreignKey.PrincipalTable,
|
||||||
|
principalColumn: foreignKey.PrincipalColumn,
|
||||||
|
onDelete: foreignKey.OnDeleteAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddPrimaryKey<TEntityBuilder>(this CreateTableBuilder<TEntityBuilder> table, PrimaryKey<TEntityBuilder> primaryKey) where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
table.PrimaryKey(primaryKey.Name, primaryKey.Columns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
Oqtane.Server/Migrations/Framework/ForeignKey.cs
Normal file
33
Oqtane.Server/Migrations/Framework/ForeignKey.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
public readonly struct ForeignKey<TEntityBuilder> where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
public ForeignKey(string name, Expression<Func<TEntityBuilder, object>> column, string principalTable, string principalColumn, ReferentialAction onDeleteAction)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Column = column;
|
||||||
|
PrincipalTable = principalTable;
|
||||||
|
PrincipalColumn = principalColumn;
|
||||||
|
OnDeleteAction = onDeleteAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
public Expression<Func<TEntityBuilder, object>> Column { get;}
|
||||||
|
|
||||||
|
public ReferentialAction OnDeleteAction { get; }
|
||||||
|
|
||||||
|
public string PrincipalTable { get; }
|
||||||
|
|
||||||
|
public string PrincipalColumn { get; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
21
Oqtane.Server/Migrations/Framework/PrimaryKey.cs
Normal file
21
Oqtane.Server/Migrations/Framework/PrimaryKey.cs
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using Oqtane.Migrations.EntityBuilders;
|
||||||
|
|
||||||
|
namespace Oqtane.Migrations
|
||||||
|
{
|
||||||
|
public readonly struct PrimaryKey<TEntityBuilder> where TEntityBuilder : BaseEntityBuilder<TEntityBuilder>
|
||||||
|
{
|
||||||
|
public PrimaryKey(string name, Expression<Func<TEntityBuilder, object>> columns)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Columns = columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
public Expression<Func<TEntityBuilder, object>> Columns { get;}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
using Oqtane.Modules.HtmlText.Models;
|
using Oqtane.Modules.HtmlText.Models;
|
||||||
using Oqtane.Repository;
|
using Oqtane.Repository;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace Oqtane.Modules.HtmlText.Repository
|
namespace Oqtane.Modules.HtmlText.Repository
|
||||||
{
|
{
|
||||||
|
@ -9,7 +10,7 @@ namespace Oqtane.Modules.HtmlText.Repository
|
||||||
{
|
{
|
||||||
public virtual DbSet<HtmlTextInfo> HtmlText { get; set; }
|
public virtual DbSet<HtmlTextInfo> HtmlText { get; set; }
|
||||||
|
|
||||||
public HtmlTextContext(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
|
public HtmlTextContext(ITenantResolver tenantResolver, IHttpContextAccessor accessor, IConfiguration configuration) : base(tenantResolver, accessor, configuration)
|
||||||
{
|
{
|
||||||
// ContextBase handles multi-tenant database connections
|
// ContextBase handles multi-tenant database connections
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,19 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dbup" Version="4.4.0" />
|
<PackageReference Include="dbup" Version="4.4.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.4" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.4">
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.0" />
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.4" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="5.0.4" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="5.0.0" />
|
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Oqtane.Client\Oqtane.Client.csproj" />
|
<ProjectReference Include="..\Oqtane.Client\Oqtane.Client.csproj" />
|
||||||
|
@ -65,4 +70,5 @@
|
||||||
<Target Name="AddPayloadsFolder" AfterTargets="Publish">
|
<Target Name="AddPayloadsFolder" AfterTargets="Publish">
|
||||||
<Copy SourceFiles="@(UpgradeFiles)" DestinationFiles="@(UpgradeFiles->'$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
|
<Copy SourceFiles="@(UpgradeFiles)" DestinationFiles="@(UpgradeFiles->'$(PublishDir)%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
|
||||||
<Copy SourceFiles="@(TemplateFiles)" DestinationFiles="@(TemplateFiles->'$(PublishDir)wwwroot\Modules\Templates\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
|
<Copy SourceFiles="@(TemplateFiles)" DestinationFiles="@(TemplateFiles->'$(PublishDir)wwwroot\Modules\Templates\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="false" />
|
||||||
</Target></Project>
|
</Target>
|
||||||
|
</Project>
|
||||||
|
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Oqtane.Extensions;
|
using Oqtane.Extensions;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
|
@ -13,11 +14,13 @@ namespace Oqtane.Repository
|
||||||
{
|
{
|
||||||
private ITenantResolver _tenantResolver;
|
private ITenantResolver _tenantResolver;
|
||||||
private IHttpContextAccessor _accessor;
|
private IHttpContextAccessor _accessor;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
|
||||||
public DBContextBase(ITenantResolver tenantResolver, IHttpContextAccessor accessor)
|
public DBContextBase(ITenantResolver tenantResolver, IHttpContextAccessor accessor, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_tenantResolver = tenantResolver;
|
_tenantResolver = tenantResolver;
|
||||||
_accessor = accessor;
|
_accessor = accessor;
|
||||||
|
_configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
@ -29,6 +32,17 @@ namespace Oqtane.Repository
|
||||||
.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString());
|
.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString());
|
||||||
optionsBuilder.UseOqtaneDatabase(connectionString);
|
optionsBuilder.UseOqtaneDatabase(connectionString);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(_configuration.GetConnectionString("DefaultConnection")))
|
||||||
|
{
|
||||||
|
var connectionString = _configuration.GetConnectionString("DefaultConnection")
|
||||||
|
.Replace("|DataDirectory|", AppDomain.CurrentDomain.GetData("DataDirectory")?.ToString());
|
||||||
|
|
||||||
|
optionsBuilder.UseOqtaneDatabase(connectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Oqtane.Models;
|
using Oqtane.Models;
|
||||||
|
|
||||||
namespace Oqtane.Repository
|
namespace Oqtane.Repository
|
||||||
|
@ -23,7 +24,7 @@ namespace Oqtane.Repository
|
||||||
|
|
||||||
public virtual DbSet<Language> Language { get; set; }
|
public virtual DbSet<Language> Language { get; set; }
|
||||||
|
|
||||||
public TenantDBContext(ITenantResolver tenantResolver, IHttpContextAccessor accessor) : base(tenantResolver, accessor)
|
public TenantDBContext(ITenantResolver tenantResolver, IHttpContextAccessor accessor, IConfiguration configuration) : base(tenantResolver, accessor, configuration)
|
||||||
{
|
{
|
||||||
// DBContextBase handles multi-tenant database connections
|
// DBContextBase handles multi-tenant database connections
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
|
||||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||||
<PackageReference Include="System.Text.Json" Version="5.0.0" />
|
<PackageReference Include="System.Text.Json" Version="5.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
|
||||||
<PackageReference Include="bunit.web" Version="1.0.0-beta-10" />
|
<PackageReference Include="bunit.web" Version="1.0.0-beta-10" />
|
||||||
<PackageReference Include="bunit.xunit" Version="1.0.0-beta-10" />
|
<PackageReference Include="bunit.xunit" Version="1.0.0-beta-10" />
|
||||||
<PackageReference Include="xunit.core" Version="2.4.1" />
|
<PackageReference Include="xunit.core" Version="2.4.1" />
|
||||||
|
|
Loading…
Reference in New Issue
Block a user