using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Marco.Pms.DataAccess.Migrations { /// public partial class CreateJobRoles : 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: "331a7bea-688e-4f27-8dba-697d9cd29870"); migrationBuilder.UpdateData( table: "Modules", keyColumn: "Id", keyValue: 2, column: "Key", value: "ba873fd2-277b-4baa-88b9-22b69010ffa8"); migrationBuilder.UpdateData( table: "Modules", keyColumn: "Id", keyValue: 3, column: "Key", value: "aa481e97-9a9b-4b1e-b9dd-0a6ce26dab47"); 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"); } } }