279 lines
9.4 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class role : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Feature_Tenants_TenantId",
table: "Feature");
migrationBuilder.DropForeignKey(
name: "FK_FeaturePermission_EmployeeRoles_RoleId",
table: "FeaturePermission");
migrationBuilder.DropForeignKey(
name: "FK_FeaturePermission_Feature_FeatureId",
table: "FeaturePermission");
migrationBuilder.DropForeignKey(
name: "FK_FeaturePermission_Tenants_TenantId",
table: "FeaturePermission");
migrationBuilder.DropIndex(
name: "IX_FeaturePermission_RoleId",
table: "FeaturePermission");
migrationBuilder.DropIndex(
name: "IX_FeaturePermission_TenantId",
table: "FeaturePermission");
migrationBuilder.DropPrimaryKey(
name: "PK_Feature",
table: "Feature");
migrationBuilder.DropColumn(
name: "RoleId",
table: "FeaturePermission");
migrationBuilder.RenameTable(
name: "Feature",
newName: "Features");
migrationBuilder.RenameIndex(
name: "IX_Feature_TenantId",
table: "Features",
newName: "IX_Features_TenantId");
migrationBuilder.AddColumn<bool>(
name: "AllowCreate",
table: "FeaturePermission",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "AllowDelete",
table: "FeaturePermission",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "AllowModify",
table: "FeaturePermission",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "AllowView",
table: "FeaturePermission",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "Description",
table: "EmployeeRoles",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<Guid>(
name: "EmployeeRoleId",
table: "Features",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddPrimaryKey(
name: "PK_Features",
table: "Features",
column: "Id");
migrationBuilder.UpdateData(
table: "EmployeeRoles",
keyColumn: "Id",
keyValue: new Guid("2c8d0808-c421-11ef-9b93-0242ac110002"),
column: "Description",
value: "");
migrationBuilder.UpdateData(
table: "EmployeeRoles",
keyColumn: "Id",
keyValue: new Guid("62e0918d-c421-11ef-9b93-0242ac110002"),
column: "Description",
value: "");
migrationBuilder.UpdateData(
table: "EmployeeRoles",
keyColumn: "Id",
keyValue: new Guid("68823f1f-c421-11ef-9b93-0242ac110002"),
column: "Description",
value: "");
migrationBuilder.UpdateData(
table: "EmployeeRoles",
keyColumn: "Id",
keyValue: new Guid("6d3a7c72-c421-11ef-9b93-0242ac110002"),
column: "Description",
value: "");
migrationBuilder.UpdateData(
table: "EmployeeRoles",
keyColumn: "Id",
keyValue: new Guid("6d3aad72-c421-11ef-9b93-0242ac110002"),
column: "Description",
value: "");
migrationBuilder.CreateIndex(
name: "IX_Features_EmployeeRoleId",
table: "Features",
column: "EmployeeRoleId");
migrationBuilder.AddForeignKey(
name: "FK_FeaturePermission_Features_FeatureId",
table: "FeaturePermission",
column: "FeatureId",
principalTable: "Features",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Features_EmployeeRoles_EmployeeRoleId",
table: "Features",
column: "EmployeeRoleId",
principalTable: "EmployeeRoles",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Features_Tenants_TenantId",
table: "Features",
column: "TenantId",
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FeaturePermission_Features_FeatureId",
table: "FeaturePermission");
migrationBuilder.DropForeignKey(
name: "FK_Features_EmployeeRoles_EmployeeRoleId",
table: "Features");
migrationBuilder.DropForeignKey(
name: "FK_Features_Tenants_TenantId",
table: "Features");
migrationBuilder.DropPrimaryKey(
name: "PK_Features",
table: "Features");
migrationBuilder.DropIndex(
name: "IX_Features_EmployeeRoleId",
table: "Features");
migrationBuilder.DropColumn(
name: "AllowCreate",
table: "FeaturePermission");
migrationBuilder.DropColumn(
name: "AllowDelete",
table: "FeaturePermission");
migrationBuilder.DropColumn(
name: "AllowModify",
table: "FeaturePermission");
migrationBuilder.DropColumn(
name: "AllowView",
table: "FeaturePermission");
migrationBuilder.DropColumn(
name: "Description",
table: "EmployeeRoles");
migrationBuilder.DropColumn(
name: "EmployeeRoleId",
table: "Features");
migrationBuilder.RenameTable(
name: "Features",
newName: "Feature");
migrationBuilder.RenameIndex(
name: "IX_Features_TenantId",
table: "Feature",
newName: "IX_Feature_TenantId");
migrationBuilder.AddColumn<Guid>(
name: "RoleId",
table: "FeaturePermission",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci");
migrationBuilder.AddPrimaryKey(
name: "PK_Feature",
table: "Feature",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_FeaturePermission_RoleId",
table: "FeaturePermission",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_FeaturePermission_TenantId",
table: "FeaturePermission",
column: "TenantId");
migrationBuilder.AddForeignKey(
name: "FK_Feature_Tenants_TenantId",
table: "Feature",
column: "TenantId",
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FeaturePermission_EmployeeRoles_RoleId",
table: "FeaturePermission",
column: "RoleId",
principalTable: "EmployeeRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FeaturePermission_Feature_FeatureId",
table: "FeaturePermission",
column: "FeatureId",
principalTable: "Feature",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_FeaturePermission_Tenants_TenantId",
table: "FeaturePermission",
column: "TenantId",
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}