using System;
using Microsoft.EntityFrameworkCore.Migrations;
using MySql.EntityFrameworkCore.Metadata;

namespace WebUI.Migrations.Engineering_ManagementMigrations
{
    public partial class managementdb : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TBL_Engineerning_TeamMember_Logs",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false, comment: "自增长")
                        .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
                    DateTime = table.Column<DateTime>(type: "datetime(3)", nullable: false, comment: "发生时间，精确到秒"),
                    UserID = table.Column<int>(type: "nvarchar(50)", nullable: false, comment: "链接到用户权限管理系统"),
                    Handler = table.Column<string>(type: "nvarchar(50)", nullable: true, comment: "处理人（谁对本条记录进行的操作）"),
                    Event = table.Column<int>(type: "int", nullable: false, comment: "事件（加入团队、移除团队）"),
                    CurrentStatus = table.Column<ulong>(type: "bit", nullable: false, comment: " 当前状态（True = 属于团队成功，  False= 不属于团队成员）"),
                    Remark = table.Column<string>(type: "nvarchar(255)", nullable: true, comment: "备注信息")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBL_Engineerning_TeamMember_Logs", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "TBL_Engineerning_TeamMembers",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false, comment: "自增长")
                        .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
                    UserID = table.Column<string>(type: "nvarchar(50)", nullable: true, comment: "链接到用户权限管理系统"),
                    UserName = table.Column<string>(type: "nvarchar(100)", nullable: true, comment: "用户名字"),
                    Department = table.Column<string>(type: "nvarchar(100)", nullable: true, comment: "部门")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBL_Engineerning_TeamMembers", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "TBL_Event_Lists",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false, comment: "自增长")
                        .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
                    CurrentStatus = table.Column<int>(type: "int", nullable: false, comment: " 当前状态（1：已提交  2：处理中   3：已处理   4：验证中  5：已关闭）"),
                    DateTime = table.Column<DateTime>(type: "datetime(3)", nullable: false, comment: "事务发生时间，精确到秒"),
                    Proposer = table.Column<string>(type: "varchar(50)", nullable: true, comment: "事务发生时间，精确到秒"),
                    EventType = table.Column<string>(type: "varchar(50)", nullable: true, comment: "事务类型"),
                    HotelID = table.Column<int>(type: "int", nullable: false, comment: "相关酒店"),
                    RoomTypeId = table.Column<int>(type: "int", nullable: false, comment: "相关户型"),
                    RoomID = table.Column<int>(type: "int", nullable: false, comment: "相关房间ID"),
                    EventDesc = table.Column<string>(type: "varchar(255)", nullable: true, comment: "事务描述"),
                    Process_Department = table.Column<string>(type: "varchar(50)", nullable: true, comment: "处理部门"),
                    Process_Handler = table.Column<string>(type: "varchar(50)", nullable: true, comment: "处理人"),
                    Process_TargetDateTime = table.Column<DateTime>(type: "datetime(3)", nullable: false, comment: "处理日期")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBL_Event_Lists", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "TBL_Event_Process_Logs",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false, comment: "自增长")
                        .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
                    EventID = table.Column<int>(type: "int", nullable: false, comment: "关联的事务ID"),
                    BeforeStatus = table.Column<int>(type: "int", nullable: false, comment: "本条处理前状态类型（1：已提交  2：处理中   3：已处理   4：验证中  5：已关闭）"),
                    AfterStatus = table.Column<int>(type: "int", nullable: false, comment: "本条处理后状态类型（1：已提交  2：处理中   3：已处理   4：验证中  5：已关闭）"),
                    ProcessType = table.Column<int>(type: "int", nullable: false, comment: "处理类型，根据处理类型事务状态将会自动进行转换.处理类型，根据处理类型事务状态将会自动进行转换"),
                    DateTime = table.Column<DateTime>(type: "datetime(3)", nullable: false, comment: "事务发生时间，精确到秒"),
                    Handle = table.Column<string>(type: "varchar(50)", nullable: true, comment: "提出人"),
                    Remark = table.Column<string>(type: "varchar(255)", nullable: true, comment: "备注")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBL_Event_Process_Logs", x => x.ID);
                });

            migrationBuilder.CreateTable(
                name: "TBL_EventType_Lists",
                columns: table => new
                {
                    ID = table.Column<int>(type: "int", nullable: false, comment: "自增长")
                        .Annotation("MySQL:ValueGenerationStrategy", MySQLValueGenerationStrategy.IdentityColumn),
                    EventName = table.Column<string>(type: "varchar(255)", nullable: true, comment: "事务名称"),
                    EventDesc = table.Column<string>(type: "varchar(255)", nullable: true, comment: "事务描述")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TBL_EventType_Lists", x => x.ID);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "TBL_Engineerning_TeamMember_Logs");

            migrationBuilder.DropTable(
                name: "TBL_Engineerning_TeamMembers");

            migrationBuilder.DropTable(
                name: "TBL_Event_Lists");

            migrationBuilder.DropTable(
                name: "TBL_Event_Process_Logs");

            migrationBuilder.DropTable(
                name: "TBL_EventType_Lists");
        }
    }
}
