using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
    /// <inheritdoc />
    public partial class Addtablecms : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "CMSCandidates",
                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"),
                    LogoImgId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    BannerImgId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    NameTh = table.Column<string>(type: "longtext", nullable: true, comment: "ชื่อเว็บภาษาไทย")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NameEn = table.Column<string>(type: "longtext", nullable: true, comment: "ชื่อเว็บภาษาอังกฤษ")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Description = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลเว็บโดยย่อ")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    About = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อมูลเกี่ยวกับเรา")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Address = table.Column<string>(type: "longtext", nullable: true, comment: "ที่อยู่")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ProvinceId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    DistrictId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    SubDistrictId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    ZipCode = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: true, comment: "รหัสไปรษณีย์")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Telephone = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: true, comment: "โทรศัพท์")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CMSCandidates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CMSCandidates_Districts_DistrictId",
                        column: x => x.DistrictId,
                        principalTable: "Districts",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_CMSCandidates_Documents_BannerImgId",
                        column: x => x.BannerImgId,
                        principalTable: "Documents",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_CMSCandidates_Documents_LogoImgId",
                        column: x => x.LogoImgId,
                        principalTable: "Documents",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_CMSCandidates_Provinces_ProvinceId",
                        column: x => x.ProvinceId,
                        principalTable: "Provinces",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_CMSCandidates_SubDistricts_SubDistrictId",
                        column: x => x.SubDistrictId,
                        principalTable: "SubDistricts",
                        principalColumn: "Id");
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_CMSCandidates_BannerImgId",
                table: "CMSCandidates",
                column: "BannerImgId");

            migrationBuilder.CreateIndex(
                name: "IX_CMSCandidates_DistrictId",
                table: "CMSCandidates",
                column: "DistrictId");

            migrationBuilder.CreateIndex(
                name: "IX_CMSCandidates_LogoImgId",
                table: "CMSCandidates",
                column: "LogoImgId");

            migrationBuilder.CreateIndex(
                name: "IX_CMSCandidates_ProvinceId",
                table: "CMSCandidates",
                column: "ProvinceId");

            migrationBuilder.CreateIndex(
                name: "IX_CMSCandidates_SubDistrictId",
                table: "CMSCandidates",
                column: "SubDistrictId");
        }

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