using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
    /// <inheritdoc />
    public partial class UpdatetablePeriodExamaddfee : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<DateTime>(
                name: "StartDate",
                table: "PeriodExams",
                type: "datetime(6)",
                nullable: false,
                comment: "วันเริ่มสมัครสอบ",
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)",
                oldComment: "วันเริ่มสมัครสอบ")
                .Annotation("Relational:ColumnOrder", 1)
                .OldAnnotation("Relational:ColumnOrder", 2);

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "PeriodExams",
                type: "varchar(150)",
                maxLength: 150,
                nullable: false,
                comment: "ชื่อการสอบ",
                oldClrType: typeof(string),
                oldType: "varchar(150)",
                oldMaxLength: 150,
                oldComment: "ชื่อการสอบ")
                .Annotation("MySql:CharSet", "utf8mb4")
                .Annotation("Relational:ColumnOrder", 4)
                .OldAnnotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("Relational:ColumnOrder", 1);

            migrationBuilder.AlterColumn<bool>(
                name: "IsActive",
                table: "PeriodExams",
                type: "tinyint(1)",
                nullable: false,
                comment: "สถานะการใช้งาน",
                oldClrType: typeof(bool),
                oldType: "tinyint(1)",
                oldComment: "สถานะการใช้งาน")
                .OldAnnotation("Relational:ColumnOrder", 5);

            migrationBuilder.AlterColumn<DateTime>(
                name: "EndDate",
                table: "PeriodExams",
                type: "datetime(6)",
                nullable: false,
                comment: "วันสิ้นสุด",
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)",
                oldComment: "วันสิ้นสุด")
                .Annotation("Relational:ColumnOrder", 2)
                .OldAnnotation("Relational:ColumnOrder", 3);

            migrationBuilder.AlterColumn<string>(
                name: "Detail",
                table: "PeriodExams",
                type: "longtext",
                nullable: true,
                comment: "รายละเอียดสมัครสอบ",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldComment: "รายละเอียดสมัครสอบ")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("Relational:ColumnOrder", 4);

            migrationBuilder.AddColumn<float>(
                name: "Fee",
                table: "PeriodExams",
                type: "float",
                nullable: true,
                comment: "ค่าธรรมเนียม");

            migrationBuilder.AddColumn<int>(
                name: "Round",
                table: "PeriodExams",
                type: "int",
                nullable: true,
                comment: "รอบการสอบ")
                .Annotation("Relational:ColumnOrder", 5);

            migrationBuilder.AddColumn<int>(
                name: "Year",
                table: "PeriodExams",
                type: "int",
                nullable: true,
                comment: "ปีงบประมาณ");

            migrationBuilder.AddColumn<DateTime>(
                name: "announceDate",
                table: "PeriodExams",
                type: "datetime(6)",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
                comment: "วันประกาศ")
                .Annotation("Relational:ColumnOrder", 3);

            migrationBuilder.AddColumn<string>(
                name: "RejectDetail",
                table: "Candidates",
                type: "longtext",
                nullable: true,
                comment: "เหตุผลการไม่อนุมัติ")
                .Annotation("MySql:CharSet", "utf8mb4");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Fee",
                table: "PeriodExams");

            migrationBuilder.DropColumn(
                name: "Round",
                table: "PeriodExams");

            migrationBuilder.DropColumn(
                name: "Year",
                table: "PeriodExams");

            migrationBuilder.DropColumn(
                name: "announceDate",
                table: "PeriodExams");

            migrationBuilder.DropColumn(
                name: "RejectDetail",
                table: "Candidates");

            migrationBuilder.AlterColumn<DateTime>(
                name: "StartDate",
                table: "PeriodExams",
                type: "datetime(6)",
                nullable: false,
                comment: "วันเริ่มสมัครสอบ",
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)",
                oldComment: "วันเริ่มสมัครสอบ")
                .Annotation("Relational:ColumnOrder", 2)
                .OldAnnotation("Relational:ColumnOrder", 1);

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "PeriodExams",
                type: "varchar(150)",
                maxLength: 150,
                nullable: false,
                comment: "ชื่อการสอบ",
                oldClrType: typeof(string),
                oldType: "varchar(150)",
                oldMaxLength: 150,
                oldComment: "ชื่อการสอบ")
                .Annotation("MySql:CharSet", "utf8mb4")
                .Annotation("Relational:ColumnOrder", 1)
                .OldAnnotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("Relational:ColumnOrder", 4);

            migrationBuilder.AlterColumn<bool>(
                name: "IsActive",
                table: "PeriodExams",
                type: "tinyint(1)",
                nullable: false,
                comment: "สถานะการใช้งาน",
                oldClrType: typeof(bool),
                oldType: "tinyint(1)",
                oldComment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 5);

            migrationBuilder.AlterColumn<DateTime>(
                name: "EndDate",
                table: "PeriodExams",
                type: "datetime(6)",
                nullable: false,
                comment: "วันสิ้นสุด",
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)",
                oldComment: "วันสิ้นสุด")
                .Annotation("Relational:ColumnOrder", 3)
                .OldAnnotation("Relational:ColumnOrder", 2);

            migrationBuilder.UpdateData(
                table: "PeriodExams",
                keyColumn: "Detail",
                keyValue: null,
                column: "Detail",
                value: "");

            migrationBuilder.AlterColumn<string>(
                name: "Detail",
                table: "PeriodExams",
                type: "longtext",
                nullable: false,
                comment: "รายละเอียดสมัครสอบ",
                oldClrType: typeof(string),
                oldType: "longtext",
                oldNullable: true,
                oldComment: "รายละเอียดสมัครสอบ")
                .Annotation("MySql:CharSet", "utf8mb4")
                .Annotation("Relational:ColumnOrder", 4)
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
