using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BMA.EHR.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class addtablecronjobprobation : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<int>(
                name: "Year",
                table: "InsigniaPeriods",
                type: "int",
                nullable: false,
                comment: "ปี",
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "InsigniaPeriods",
                type: "varchar(10)",
                maxLength: 10,
                nullable: true,
                comment: "ประเภทการขอ",
                oldClrType: typeof(string),
                oldType: "varchar(10)",
                oldMaxLength: 10,
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<DateTime>(
                name: "StartDate",
                table: "InsigniaPeriods",
                type: "datetime(6)",
                nullable: false,
                comment: "วันที่เริ่ม",
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "InsigniaPeriods",
                type: "varchar(200)",
                maxLength: 200,
                nullable: true,
                comment: "ชื่อรอบเสนอขอเครื่องราชฯ",
                oldClrType: typeof(string),
                oldType: "varchar(200)",
                oldMaxLength: 200,
                oldNullable: true)
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<DateTime>(
                name: "EndDate",
                table: "InsigniaPeriods",
                type: "datetime(6)",
                nullable: false,
                comment: "วันที่สิ้นสุด",
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)");

            migrationBuilder.AlterColumn<int>(
                name: "Amount",
                table: "InsigniaPeriods",
                type: "int",
                maxLength: 50,
                nullable: false,
                comment: "จำนวนวันแจ้งเตือนล่วงหน้า",
                oldClrType: typeof(int),
                oldType: "int",
                oldMaxLength: 50);

            migrationBuilder.CreateTable(
                name: "CronjobNotiProbations",
                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"),
                    Subject = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "หัวเรื่อง")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Body = table.Column<string>(type: "text", nullable: false, comment: "รายละเอียดข้อความ")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ReceiverUserId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัสผู้รับข้อความ", collation: "ascii_general_ci"),
                    Payload = table.Column<string>(type: "text", nullable: false, comment: "สิงที่แนบมาด้วย")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    IsSendMail = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งอีเมล์หรือไม่?"),
                    IsSendInbox = table.Column<bool>(type: "tinyint(1)", nullable: false, comment: "ส่งกล่องข้อความหรือไม่?"),
                    ReceiveDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "วันที่ได้รับ")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CronjobNotiProbations", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");
        }

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

            migrationBuilder.AlterColumn<int>(
                name: "Year",
                table: "InsigniaPeriods",
                type: "int",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "int",
                oldComment: "ปี");

            migrationBuilder.AlterColumn<string>(
                name: "Type",
                table: "InsigniaPeriods",
                type: "varchar(10)",
                maxLength: 10,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(10)",
                oldMaxLength: 10,
                oldNullable: true,
                oldComment: "ประเภทการขอ")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<DateTime>(
                name: "StartDate",
                table: "InsigniaPeriods",
                type: "datetime(6)",
                nullable: false,
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)",
                oldComment: "วันที่เริ่ม");

            migrationBuilder.AlterColumn<string>(
                name: "Name",
                table: "InsigniaPeriods",
                type: "varchar(200)",
                maxLength: 200,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "varchar(200)",
                oldMaxLength: 200,
                oldNullable: true,
                oldComment: "ชื่อรอบเสนอขอเครื่องราชฯ")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<DateTime>(
                name: "EndDate",
                table: "InsigniaPeriods",
                type: "datetime(6)",
                nullable: false,
                oldClrType: typeof(DateTime),
                oldType: "datetime(6)",
                oldComment: "วันที่สิ้นสุด");

            migrationBuilder.AlterColumn<int>(
                name: "Amount",
                table: "InsigniaPeriods",
                type: "int",
                maxLength: 50,
                nullable: false,
                oldClrType: typeof(int),
                oldType: "int",
                oldMaxLength: 50,
                oldComment: "จำนวนวันแจ้งเตือนล่วงหน้า");
        }
    }
}
