using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
    /// <inheritdoc />
    public partial class updatetableperiodaddqrcode : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "ScoreImports");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "PositionExams");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "PeriodExamImages");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "PeriodExamDocuments");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "Educations");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisableScores");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "Disables");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisablePayments");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisableOccupations");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisableImportHistories");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisableEducations");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisableDocuments");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisableCertificates");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "DisableAddresses");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "CMSGovernments");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "CMSCandidates");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "CMSAgencys");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "Careers");

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

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "CandidateDocuments");

            migrationBuilder.DropColumn(
                name: "IsActive",
                table: "BankExams");

            migrationBuilder.AddColumn<string>(
                name: "CompanyCode",
                table: "PeriodExams",
                type: "longtext",
                nullable: true,
                comment: "Company code")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "CustomerName",
                table: "PeriodExams",
                type: "longtext",
                nullable: true,
                comment: "Customer name")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Reason",
                table: "PeriodExams",
                type: "text",
                nullable: true,
                comment: "หมายเหตุ")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "RefNo1",
                table: "PeriodExams",
                type: "longtext",
                nullable: true,
                comment: "Ref No1")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AddColumn<string>(
                name: "Remark",
                table: "PeriodExams",
                type: "text",
                nullable: true,
                comment: "remark")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PeriodExamBarCodes",
                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"),
                    PeriodExamId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PeriodExamBarCodes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PeriodExamBarCodes_Documents_DocumentId",
                        column: x => x.DocumentId,
                        principalTable: "Documents",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PeriodExamBarCodes_PeriodExams_PeriodExamId",
                        column: x => x.PeriodExamId,
                        principalTable: "PeriodExams",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "PeriodExamQrCodes",
                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"),
                    PeriodExamId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_PeriodExamQrCodes", x => x.Id);
                    table.ForeignKey(
                        name: "FK_PeriodExamQrCodes_Documents_DocumentId",
                        column: x => x.DocumentId,
                        principalTable: "Documents",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_PeriodExamQrCodes_PeriodExams_PeriodExamId",
                        column: x => x.PeriodExamId,
                        principalTable: "PeriodExams",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_PeriodExamBarCodes_DocumentId",
                table: "PeriodExamBarCodes",
                column: "DocumentId");

            migrationBuilder.CreateIndex(
                name: "IX_PeriodExamBarCodes_PeriodExamId",
                table: "PeriodExamBarCodes",
                column: "PeriodExamId");

            migrationBuilder.CreateIndex(
                name: "IX_PeriodExamQrCodes_DocumentId",
                table: "PeriodExamQrCodes",
                column: "DocumentId");

            migrationBuilder.CreateIndex(
                name: "IX_PeriodExamQrCodes_PeriodExamId",
                table: "PeriodExamQrCodes",
                column: "PeriodExamId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "PeriodExamBarCodes");

            migrationBuilder.DropTable(
                name: "PeriodExamQrCodes");

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

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

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

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

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

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "ScoreImports",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "PositionExams",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "PeriodExamImages",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "PeriodExamDocuments",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "Educations",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisableScores",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "Disables",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisablePayments",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisableOccupations",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisableImportHistories",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisableEducations",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisableDocuments",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisableCertificates",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "DisableAddresses",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "CMSGovernments",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "CMSCandidates",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "CMSAgencys",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "Careers",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "Candidates",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "CandidateDocuments",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);

            migrationBuilder.AddColumn<bool>(
                name: "IsActive",
                table: "BankExams",
                type: "tinyint(1)",
                nullable: false,
                defaultValue: false,
                comment: "สถานะการใช้งาน")
                .Annotation("Relational:ColumnOrder", 106);
        }
    }
}
