using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace RB_MES_APICore.Migrations
{
    public partial class appinfo : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "APIGrou",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FName = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
                    FVersion = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
                    FTokenUrl = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_APIGrou", x => x.FID);
                });

            migrationBuilder.CreateTable(
                name: "r_ClumnConvert",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FFunctionID = table.Column<int>(type: "int", nullable: false),
                    FDesTableName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    FSourceName = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FDesName = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FKDCaption = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_ClumnConvert", x => x.FID);
                });

            migrationBuilder.CreateTable(
                name: "r_MesRequestStatus",
                columns: table => new
                {
                    FID = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    FERPBillType = table.Column<int>(type: "int", nullable: false),
                    FERPBillID = table.Column<int>(type: "int", nullable: false),
                    FERPBillEntryID = table.Column<int>(type: "int", nullable: false),
                    FIMSDocType = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FRequestKey = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FStatus = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_MesRequestStatus", x => new { x.FID, x.FERPBillType, x.FERPBillID, x.FERPBillEntryID });
                });

            migrationBuilder.CreateTable(
                name: "r_SystemProfiles",
                columns: table => new
                {
                    FCategoryID = table.Column<int>(type: "int", nullable: false),
                    FKey = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    FID = table.Column<int>(type: "int", nullable: false),
                    FValue = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    FReadonly = table.Column<bool>(type: "bit", nullable: false),
                    FDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    FLevel = table.Column<int>(type: "int", nullable: false),
                    FParentID = table.Column<int>(type: "int", nullable: false),
                    FFormatID = table.Column<int>(type: "int", nullable: false),
                    FDetail = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_SystemProfiles", x => new { x.FCategoryID, x.FKey });
                });

            migrationBuilder.CreateTable(
                name: "RBLog",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FFunctionID = table.Column<int>(type: "int", nullable: false),
                    FDocType = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FDateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    FStatus = table.Column<bool>(type: "bit", nullable: false),
                    FMess = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    FSource = table.Column<string>(type: "xml", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RBLog", x => x.FID);
                });

            migrationBuilder.CreateTable(
                name: "r_FunctionList",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FGoupID = table.Column<int>(type: "int", nullable: false),
                    FFunctionName = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FInterfaceType = table.Column<int>(type: "int", nullable: false),
                    FUrl = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    FDescription = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false),
                    FUsing = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_FunctionList", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_FunctionList_APIGrou_FGoupID",
                        column: x => x.FGoupID,
                        principalTable: "APIGrou",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_FormIDType",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FFunctionID = table.Column<int>(type: "int", nullable: false),
                    FActionName = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FDocType = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FDBName = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FUsing = table.Column<bool>(type: "bit", nullable: false),
                    FIsHostService = table.Column<bool>(type: "bit", nullable: false),
                    FDescription = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_FormIDType", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_FormIDType_r_FunctionList_FFunctionID",
                        column: x => x.FFunctionID,
                        principalTable: "r_FunctionList",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_ReceiveStockBillTypes",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FFunctionID = table.Column<int>(type: "int", nullable: false),
                    ErpBillTypeID = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ErpBillName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FROB = table.Column<bool>(type: "bit", nullable: false),
                    FHeadTbName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FEntryTbName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FStatus = table.Column<int>(type: "int", nullable: false),
                    FDefaultUserid = table.Column<int>(type: "int", nullable: false),
                    FDefaultDepid = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_ReceiveStockBillTypes", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_ReceiveStockBillTypes_r_FunctionList_FFunctionID",
                        column: x => x.FFunctionID,
                        principalTable: "r_FunctionList",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_SelectJoinID",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FFunctionID = table.Column<int>(type: "int", nullable: false),
                    FDocType = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FOptcode = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_SelectJoinID", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_SelectJoinID_r_FunctionList_FFunctionID",
                        column: x => x.FFunctionID,
                        principalTable: "r_FunctionList",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_CloudBillQuery",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FFormIDTypeID = table.Column<int>(type: "int", maxLength: 80, nullable: false),
                    FFieldKeys = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FKDBillName = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FRBBillName = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false),
                    FFiledString = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FOrderString = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FTopRowCount = table.Column<int>(type: "int", nullable: false),
                    FStartRow = table.Column<int>(type: "int", nullable: false),
                    FLimit = table.Column<int>(type: "int", nullable: false),
                    FSubSystemID = table.Column<string>(type: "nvarchar(80)", maxLength: 80, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_CloudBillQuery", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_CloudBillQuery_r_FormIDType_FFormIDTypeID",
                        column: x => x.FFormIDTypeID,
                        principalTable: "r_FormIDType",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_BillConvertes",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FReceiveID = table.Column<int>(type: "int", nullable: false),
                    FPageID = table.Column<int>(type: "int", nullable: false),
                    FSourceName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FK3FiledName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FNeedInput = table.Column<bool>(type: "bit", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_BillConvertes", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_BillConvertes_r_ReceiveStockBillTypes_FReceiveID",
                        column: x => x.FReceiveID,
                        principalTable: "r_ReceiveStockBillTypes",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_K3DefaultColVals",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FReceiveID = table.Column<int>(type: "int", nullable: false),
                    FPageID = table.Column<int>(type: "int", nullable: false),
                    K3FiledName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FSqlType = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FVal = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
                    FDescribe = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_K3DefaultColVals", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_K3DefaultColVals_r_ReceiveStockBillTypes_FReceiveID",
                        column: x => x.FReceiveID,
                        principalTable: "r_ReceiveStockBillTypes",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_JoinTb",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FSID = table.Column<int>(type: "int", nullable: false),
                    FCtlID = table.Column<int>(type: "int", nullable: false),
                    FTbName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: false),
                    FAsName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    FJoinType = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    FJoinSymbol = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
                    FCondition = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_JoinTb", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_JoinTb_r_SelectJoinID_FSID",
                        column: x => x.FSID,
                        principalTable: "r_SelectJoinID",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "r_SCol",
                columns: table => new
                {
                    FID = table.Column<int>(type: "int", nullable: false)
                        .Annotation("SqlServer:Identity", "1, 1"),
                    FSID = table.Column<int>(type: "int", nullable: false),
                    FCtlID = table.Column<int>(type: "int", nullable: false),
                    FAsTable = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    FColName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false),
                    FDeaful = table.Column<string>(type: "nvarchar(2000)", maxLength: 2000, nullable: false),
                    FAsName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_r_SCol", x => x.FID);
                    table.ForeignKey(
                        name: "FK_r_SCol_r_SelectJoinID_FSID",
                        column: x => x.FSID,
                        principalTable: "r_SelectJoinID",
                        principalColumn: "FID",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_r_BillConvertes_FReceiveID_FPageID_FK3FiledName",
                table: "r_BillConvertes",
                columns: new[] { "FReceiveID", "FPageID", "FK3FiledName" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_r_CloudBillQuery_FFormIDTypeID",
                table: "r_CloudBillQuery",
                column: "FFormIDTypeID",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_r_ClumnConvert_FFunctionID",
                table: "r_ClumnConvert",
                column: "FFunctionID");

            migrationBuilder.CreateIndex(
                name: "IX_r_FormIDType_FFunctionID_FDocType",
                table: "r_FormIDType",
                columns: new[] { "FFunctionID", "FDocType" });

            migrationBuilder.CreateIndex(
                name: "IX_r_FunctionList_FGoupID",
                table: "r_FunctionList",
                column: "FGoupID");

            migrationBuilder.CreateIndex(
                name: "IX_r_JoinTb_FSID_FCtlID",
                table: "r_JoinTb",
                columns: new[] { "FSID", "FCtlID" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_r_K3DefaultColVals_FReceiveID_FPageID_K3FiledName",
                table: "r_K3DefaultColVals",
                columns: new[] { "FReceiveID", "FPageID", "K3FiledName" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_r_ReceiveStockBillTypes_FFunctionID_ErpBillTypeID",
                table: "r_ReceiveStockBillTypes",
                columns: new[] { "FFunctionID", "ErpBillTypeID" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_r_SCol_FSID_FAsName",
                table: "r_SCol",
                columns: new[] { "FSID", "FAsName" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_r_SCol_FSID_FCtlID",
                table: "r_SCol",
                columns: new[] { "FSID", "FCtlID" },
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_r_SelectJoinID_FDocType",
                table: "r_SelectJoinID",
                column: "FDocType");

            migrationBuilder.CreateIndex(
                name: "IX_r_SelectJoinID_FFunctionID",
                table: "r_SelectJoinID",
                column: "FFunctionID");

            migrationBuilder.CreateIndex(
                name: "IX_RBLog_FDateTime_FDocType",
                table: "RBLog",
                columns: new[] { "FDateTime", "FDocType" });
        }

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

            migrationBuilder.DropTable(
                name: "r_CloudBillQuery");

            migrationBuilder.DropTable(
                name: "r_ClumnConvert");

            migrationBuilder.DropTable(
                name: "r_JoinTb");

            migrationBuilder.DropTable(
                name: "r_K3DefaultColVals");

            migrationBuilder.DropTable(
                name: "r_MesRequestStatus");

            migrationBuilder.DropTable(
                name: "r_SCol");

            migrationBuilder.DropTable(
                name: "r_SystemProfiles");

            migrationBuilder.DropTable(
                name: "RBLog");

            migrationBuilder.DropTable(
                name: "r_FormIDType");

            migrationBuilder.DropTable(
                name: "r_ReceiveStockBillTypes");

            migrationBuilder.DropTable(
                name: "r_SelectJoinID");

            migrationBuilder.DropTable(
                name: "r_FunctionList");

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