using System; using Microsoft.EntityFrameworkCore.Migrations; namespace Ropin.Inspection.Model.Migrations { public partial class EditBDM : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "TBDM_CodeDetail", columns: table => new { C_Code = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), C_MainCode = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), C_Name = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), C_Value = table.Column(type: "varchar(255) CHARACTER SET utf8mb4", maxLength: 255, nullable: false), C_IsSys = table.Column(type: "varchar(1) CHARACTER SET utf8mb4", maxLength: 1, nullable: false), C_Default = table.Column(type: "varchar(1) CHARACTER SET utf8mb4", maxLength: 1, nullable: false), I_Sort = table.Column(type: "int", nullable: false), C_Remark = table.Column(type: "varchar(500) CHARACTER SET utf8mb4", maxLength: 500, nullable: true), C_CreateBy = table.Column(type: "char(36)", nullable: false), D_CreateOn = table.Column(type: "datetime(6)", nullable: false), C_LastUpdatedBy = table.Column(type: "char(36)", nullable: true), D_LastUpdatedOn = table.Column(type: "datetime(6)", nullable: true), C_Status = table.Column(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TBDM_CodeDetail", x => x.C_Code); table.ForeignKey( name: "FK_TBDM_CodeDetail_TSYS_User_C_CreateBy", column: x => x.C_CreateBy, principalTable: "TSYS_User", principalColumn: "C_UserID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TBDM_CodeDetail_TSYS_User_C_LastUpdatedBy", column: x => x.C_LastUpdatedBy, principalTable: "TSYS_User", principalColumn: "C_UserID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TBDM_CodeMain", columns: table => new { C_Code = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), C_Name = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), I_Sort = table.Column(type: "int", nullable: false), C_Remark = table.Column(type: "varchar(500) CHARACTER SET utf8mb4", maxLength: 500, nullable: true), C_CreateBy = table.Column(type: "char(36)", nullable: false), D_CreateOn = table.Column(type: "datetime(6)", nullable: false), C_LastUpdatedBy = table.Column(type: "char(36)", nullable: true), D_LastUpdatedOn = table.Column(type: "datetime(6)", nullable: true), C_Status = table.Column(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TBDM_CodeMain", x => x.C_Code); table.ForeignKey( name: "FK_TBDM_CodeMain_TSYS_User_C_CreateBy", column: x => x.C_CreateBy, principalTable: "TSYS_User", principalColumn: "C_UserID", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_TBDM_CodeMain_TSYS_User_C_LastUpdatedBy", column: x => x.C_LastUpdatedBy, principalTable: "TSYS_User", principalColumn: "C_UserID", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TBDM_Prov", columns: table => new { C_Code = table.Column(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false), C_Name = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), I_Sort = table.Column(type: "int", nullable: false), C_Status = table.Column(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TBDM_Prov", x => x.C_Code); }); migrationBuilder.CreateTable( name: "TBDM_City", columns: table => new { C_Code = table.Column(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false), C_ProvCode = table.Column(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false), C_Name = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), I_Sort = table.Column(type: "int", nullable: false), C_Status = table.Column(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TBDM_City", x => x.C_Code); table.ForeignKey( name: "FK_TBDM_City_TBDM_Prov_C_ProvCode", column: x => x.C_ProvCode, principalTable: "TBDM_Prov", principalColumn: "C_Code", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "TBDM_Area", columns: table => new { C_Code = table.Column(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false), C_CityCode = table.Column(type: "varchar(20) CHARACTER SET utf8mb4", maxLength: 20, nullable: false), C_Name = table.Column(type: "varchar(50) CHARACTER SET utf8mb4", maxLength: 50, nullable: false), I_Sort = table.Column(type: "int", nullable: false), C_Status = table.Column(type: "varchar(1) CHARACTER SET utf8mb4", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TBDM_Area", x => x.C_Code); table.ForeignKey( name: "FK_TBDM_Area_TBDM_City_C_CityCode", column: x => x.C_CityCode, principalTable: "TBDM_City", principalColumn: "C_Code", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_TBDM_Area_C_CityCode", table: "TBDM_Area", column: "C_CityCode"); migrationBuilder.CreateIndex( name: "IX_TBDM_City_C_ProvCode", table: "TBDM_City", column: "C_ProvCode"); migrationBuilder.CreateIndex( name: "IX_TBDM_CodeDetail_C_CreateBy", table: "TBDM_CodeDetail", column: "C_CreateBy"); migrationBuilder.CreateIndex( name: "IX_TBDM_CodeDetail_C_LastUpdatedBy", table: "TBDM_CodeDetail", column: "C_LastUpdatedBy"); migrationBuilder.CreateIndex( name: "IX_TBDM_CodeMain_C_CreateBy", table: "TBDM_CodeMain", column: "C_CreateBy"); migrationBuilder.CreateIndex( name: "IX_TBDM_CodeMain_C_LastUpdatedBy", table: "TBDM_CodeMain", column: "C_LastUpdatedBy"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "TBDM_Area"); migrationBuilder.DropTable( name: "TBDM_CodeDetail"); migrationBuilder.DropTable( name: "TBDM_CodeMain"); migrationBuilder.DropTable( name: "TBDM_City"); migrationBuilder.DropTable( name: "TBDM_Prov"); } } }