using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Marco.Pms.DataAccess.Migrations
{
///
public partial class addjobrole : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RoleId",
table: "Employees");
migrationBuilder.AddColumn(
name: "JobRoleId",
table: "Employees",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "JobRoles",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Description = table.Column(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
TenantId = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_JobRoles", x => x.Id);
table.ForeignKey(
name: "FK_JobRoles_Tenants_TenantId",
column: x => x.TenantId,
principalTable: "Tenants",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 1,
column: "Key",
value: "ad9fb730-b80a-446c-bf49-bf41f90e0c0b");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 2,
column: "Key",
value: "bc153ba8-7f38-4b91-97d5-1deb230250a9");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 3,
column: "Key",
value: "44e296ca-5597-44c9-9159-b481c941f902");
migrationBuilder.CreateIndex(
name: "IX_Employees_JobRoleId",
table: "Employees",
column: "JobRoleId");
migrationBuilder.CreateIndex(
name: "IX_JobRoles_TenantId",
table: "JobRoles",
column: "TenantId");
migrationBuilder.AddForeignKey(
name: "FK_Employees_JobRoles_JobRoleId",
table: "Employees",
column: "JobRoleId",
principalTable: "JobRoles",
principalColumn: "Id");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Employees_JobRoles_JobRoleId",
table: "Employees");
migrationBuilder.DropTable(
name: "JobRoles");
migrationBuilder.DropIndex(
name: "IX_Employees_JobRoleId",
table: "Employees");
migrationBuilder.DropColumn(
name: "JobRoleId",
table: "Employees");
migrationBuilder.AddColumn(
name: "RoleId",
table: "Employees",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 1,
column: "Key",
value: "05db8d60-e977-40f6-b944-8602d0d4cb98");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 2,
column: "Key",
value: "456ddbbe-0963-406d-8874-589a546c3670");
migrationBuilder.UpdateData(
table: "Modules",
keyColumn: "Id",
keyValue: 3,
column: "Key",
value: "19eca67f-c3b1-4e5c-8d95-c8341cf058ae");
}
}
}