140 lines
5.6 KiB
C#
140 lines
5.6 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
|
|
|
namespace Marco.Pms.DataAccess.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class RolePermissionMappings : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "ApplicationRoles",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
Role = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Description = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
TenantId = table.Column<int>(type: "int", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_ApplicationRoles", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_ApplicationRoles_Tenants_TenantId",
|
|
column: x => x.TenantId,
|
|
principalTable: "Tenants",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "RolePermissionMappings",
|
|
columns: table => new
|
|
{
|
|
ApplicationRoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
|
FeaturePermissionId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_RolePermissionMappings", x => new { x.ApplicationRoleId, x.FeaturePermissionId });
|
|
table.ForeignKey(
|
|
name: "FK_RolePermissionMappings_ApplicationRoles_ApplicationRoleId",
|
|
column: x => x.ApplicationRoleId,
|
|
principalTable: "ApplicationRoles",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_RolePermissionMappings_FeaturePermissions_FeaturePermissionId",
|
|
column: x => x.FeaturePermissionId,
|
|
principalTable: "FeaturePermissions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.InsertData(
|
|
table: "ApplicationRoles",
|
|
columns: new[] { "Id", "Description", "Role", "TenantId" },
|
|
values: new object[,]
|
|
{
|
|
{ new Guid("2c8d0808-c421-11ef-9b93-0242ac110002"), "", "Admin", 1 },
|
|
{ new Guid("62e0918d-c421-11ef-9b93-0242ac110002"), "", "Welder", 1 },
|
|
{ new Guid("68823f1f-c421-11ef-9b93-0242ac110002"), "", "Helper", 1 },
|
|
{ new Guid("6d3a7c72-c421-11ef-9b93-0242ac110002"), "", "Site Engineer", 1 },
|
|
{ new Guid("6d3aad72-c421-11ef-9b93-0242ac110002"), "", "Project Manager", 1 }
|
|
});
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "Modules",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "Key",
|
|
value: "286516c2-0d55-439c-a8fa-b6858735ef65");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "Modules",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "Key",
|
|
value: "6a84b9c0-1478-4d87-9ef6-34c00f0fca4a");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "Modules",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "Key",
|
|
value: "c38971e1-491e-479f-9d02-54634c0b4908");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_ApplicationRoles_TenantId",
|
|
table: "ApplicationRoles",
|
|
column: "TenantId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_RolePermissionMappings_FeaturePermissionId",
|
|
table: "RolePermissionMappings",
|
|
column: "FeaturePermissionId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "RolePermissionMappings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "ApplicationRoles");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "Modules",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
column: "Key",
|
|
value: "235d7bb6-9fae-4cdc-bc62-2426059cd49e");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "Modules",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
column: "Key",
|
|
value: "e60119bf-48b1-4534-82ae-88d23ae46f15");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "Modules",
|
|
keyColumn: "Id",
|
|
keyValue: 3,
|
|
column: "Key",
|
|
value: "9090b0dd-7a3c-46f7-82e5-816eb6c416d2");
|
|
}
|
|
}
|
|
}
|