hrms-api-backend/BMA.EHR.Infrastructure/Migrations/20230720050033_Change Command Table.cs
2023-07-20 14:53:09 +07:00

314 lines
13 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class ChangeCommandTable : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Command_CommandStatuses_CommandStatusId",
table: "Command");
migrationBuilder.DropForeignKey(
name: "FK_Command_CommandTypes_CommandTypeId",
table: "Command");
migrationBuilder.DropForeignKey(
name: "FK_CommandDocuments_Command_CommandId",
table: "CommandDocuments");
migrationBuilder.DropPrimaryKey(
name: "PK_Command",
table: "Command");
migrationBuilder.DropColumn(
name: "Discriminator",
table: "Command");
migrationBuilder.RenameTable(
name: "Command",
newName: "Commands");
migrationBuilder.RenameIndex(
name: "IX_Command_CommandTypeId",
table: "Commands",
newName: "IX_Commands_CommandTypeId");
migrationBuilder.RenameIndex(
name: "IX_Command_CommandStatusId",
table: "Commands",
newName: "IX_Commands_CommandStatusId");
migrationBuilder.UpdateData(
table: "Commands",
keyColumn: "PositionName",
keyValue: null,
column: "PositionName",
value: "");
migrationBuilder.AlterColumn<string>(
name: "PositionName",
table: "Commands",
type: "longtext",
nullable: false,
comment: "ตำแหน่งที่บรรจุ",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "ตำแหน่งที่บรรจุ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<Guid>(
name: "ExamRoundId",
table: "Commands",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
comment: "อ้างอิงรอบการสอบ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "อ้างอิงรอบการสอบ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.UpdateData(
table: "Commands",
keyColumn: "ConclusionResultNo",
keyValue: null,
column: "ConclusionResultNo",
value: "");
migrationBuilder.AlterColumn<string>(
name: "ConclusionResultNo",
table: "Commands",
type: "longtext",
nullable: false,
comment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionResultDate",
table: "Commands",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
comment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldNullable: true,
oldComment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)");
migrationBuilder.UpdateData(
table: "Commands",
keyColumn: "ConclusionRegisterNo",
keyValue: null,
column: "ConclusionRegisterNo",
value: "");
migrationBuilder.AlterColumn<string>(
name: "ConclusionRegisterNo",
table: "Commands",
type: "longtext",
nullable: false,
comment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionRegisterDate",
table: "Commands",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
comment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldNullable: true,
oldComment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)");
migrationBuilder.AddPrimaryKey(
name: "PK_Commands",
table: "Commands",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_CommandDocuments_Commands_CommandId",
table: "CommandDocuments",
column: "CommandId",
principalTable: "Commands",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Commands_CommandStatuses_CommandStatusId",
table: "Commands",
column: "CommandStatusId",
principalTable: "CommandStatuses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Commands_CommandTypes_CommandTypeId",
table: "Commands",
column: "CommandTypeId",
principalTable: "CommandTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_CommandDocuments_Commands_CommandId",
table: "CommandDocuments");
migrationBuilder.DropForeignKey(
name: "FK_Commands_CommandStatuses_CommandStatusId",
table: "Commands");
migrationBuilder.DropForeignKey(
name: "FK_Commands_CommandTypes_CommandTypeId",
table: "Commands");
migrationBuilder.DropPrimaryKey(
name: "PK_Commands",
table: "Commands");
migrationBuilder.RenameTable(
name: "Commands",
newName: "Command");
migrationBuilder.RenameIndex(
name: "IX_Commands_CommandTypeId",
table: "Command",
newName: "IX_Command_CommandTypeId");
migrationBuilder.RenameIndex(
name: "IX_Commands_CommandStatusId",
table: "Command",
newName: "IX_Command_CommandStatusId");
migrationBuilder.AlterColumn<string>(
name: "PositionName",
table: "Command",
type: "longtext",
nullable: true,
comment: "ตำแหน่งที่บรรจุ",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "ตำแหน่งที่บรรจุ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<Guid>(
name: "ExamRoundId",
table: "Command",
type: "char(36)",
nullable: true,
comment: "อ้างอิงรอบการสอบ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldComment: "อ้างอิงรอบการสอบ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<string>(
name: "ConclusionResultNo",
table: "Command",
type: "longtext",
nullable: true,
comment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "มติ กก. ครั้งที่ (เรื่อง ผลการสอบแข่งขัน)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionResultDate",
table: "Command",
type: "datetime(6)",
nullable: true,
comment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldComment: "ลงวันที่ (เรื่อง ผลการสอบแข่งขัน)");
migrationBuilder.AlterColumn<string>(
name: "ConclusionRegisterNo",
table: "Command",
type: "longtext",
nullable: true,
comment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "มติ กก. ครั้งที่ (เรื่อง รับสมัครสอบฯ)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<DateTime>(
name: "ConclusionRegisterDate",
table: "Command",
type: "datetime(6)",
nullable: true,
comment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)",
oldClrType: typeof(DateTime),
oldType: "datetime(6)",
oldComment: "ลงวันที่ (เรื่อง รับสมัครสอบฯ)");
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "Command",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddPrimaryKey(
name: "PK_Command",
table: "Command",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Command_CommandStatuses_CommandStatusId",
table: "Command",
column: "CommandStatusId",
principalTable: "CommandStatuses",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Command_CommandTypes_CommandTypeId",
table: "Command",
column: "CommandTypeId",
principalTable: "CommandTypes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_CommandDocuments_Command_CommandId",
table: "CommandDocuments",
column: "CommandId",
principalTable: "Command",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}