hrms-api-backend/BMA.EHR.Infrastructure/Migrations/20230722131911_update Table retire to RetirementPeriod.cs
2023-07-22 22:14:50 +07:00

119 lines
6.6 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updateTableretiretoRetirementPeriod : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_RetirementProfiles_Retirements_RetirementId",
table: "RetirementProfiles");
migrationBuilder.DropTable(
name: "Retirements");
migrationBuilder.RenameColumn(
name: "RetirementId",
table: "RetirementProfiles",
newName: "RetirementPeriodId");
migrationBuilder.RenameIndex(
name: "IX_RetirementProfiles_RetirementId",
table: "RetirementProfiles",
newName: "IX_RetirementProfiles_RetirementPeriodId");
migrationBuilder.CreateTable(
name: "RetirementPeriods",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ครั้งที่"),
Type = table.Column<string>(type: "longtext", nullable: false, comment: "ประเภท")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_RetirementPeriods", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddForeignKey(
name: "FK_RetirementProfiles_RetirementPeriods_RetirementPeriodId",
table: "RetirementProfiles",
column: "RetirementPeriodId",
principalTable: "RetirementPeriods",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_RetirementProfiles_RetirementPeriods_RetirementPeriodId",
table: "RetirementProfiles");
migrationBuilder.DropTable(
name: "RetirementPeriods");
migrationBuilder.RenameColumn(
name: "RetirementPeriodId",
table: "RetirementProfiles",
newName: "RetirementId");
migrationBuilder.RenameIndex(
name: "IX_RetirementProfiles_RetirementPeriodId",
table: "RetirementProfiles",
newName: "IX_RetirementProfiles_RetirementId");
migrationBuilder.CreateTable(
name: "Retirements",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ครั้งที่"),
Type = table.Column<string>(type: "longtext", nullable: false, comment: "ประเภท")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Retirements", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddForeignKey(
name: "FK_RetirementProfiles_Retirements_RetirementId",
table: "RetirementProfiles",
column: "RetirementId",
principalTable: "Retirements",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}