using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Recurit.Exam.Service.Migrations
{
///
public partial class updatetablemetadatausekeymain : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Districts_CitizenDistrictId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Districts_CurrentDistrictId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Districts_RegistDistrictId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Prefixes_FatherPrefixId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Prefixes_MarryPrefixId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Prefixes_MotherPrefixId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Prefixes_PrefixId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Provinces_CitizenProvinceId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Provinces_CurrentProvinceId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Provinces_RegistProvinceId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_Relationships_RelationshipId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_SubDistricts_CurrentSubDistrictId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_Candidates_SubDistricts_RegistSubDistrictId",
table: "Candidates");
migrationBuilder.DropForeignKey(
name: "FK_CMSCandidates_Districts_DistrictId",
table: "CMSCandidates");
migrationBuilder.DropForeignKey(
name: "FK_CMSCandidates_Provinces_ProvinceId",
table: "CMSCandidates");
migrationBuilder.DropForeignKey(
name: "FK_CMSCandidates_SubDistricts_SubDistrictId",
table: "CMSCandidates");
migrationBuilder.DropForeignKey(
name: "FK_Educations_EducationLevels_EducationLevelId",
table: "Educations");
migrationBuilder.DropTable(
name: "EducationLevels");
migrationBuilder.DropTable(
name: "Prefixes");
migrationBuilder.DropTable(
name: "Relationships");
migrationBuilder.DropTable(
name: "Religions");
migrationBuilder.DropTable(
name: "SubDistricts");
migrationBuilder.DropTable(
name: "Districts");
migrationBuilder.DropTable(
name: "Provinces");
migrationBuilder.DropIndex(
name: "IX_Educations_EducationLevelId",
table: "Educations");
migrationBuilder.DropIndex(
name: "IX_CMSCandidates_DistrictId",
table: "CMSCandidates");
migrationBuilder.DropIndex(
name: "IX_CMSCandidates_ProvinceId",
table: "CMSCandidates");
migrationBuilder.DropIndex(
name: "IX_CMSCandidates_SubDistrictId",
table: "CMSCandidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_CitizenDistrictId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_CitizenProvinceId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_CurrentDistrictId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_CurrentProvinceId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_CurrentSubDistrictId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_FatherPrefixId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_MarryPrefixId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_MotherPrefixId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_PrefixId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_RegistDistrictId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_RegistProvinceId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_RegistSubDistrictId",
table: "Candidates");
migrationBuilder.DropIndex(
name: "IX_Candidates_RelationshipId",
table: "Candidates");
migrationBuilder.AlterColumn(
name: "EducationLevelId",
table: "Educations",
type: "char(36)",
nullable: true,
comment: "Idวุฒิที่ได้รับ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn(
name: "EducationLevelName",
table: "Educations",
type: "longtext",
nullable: true,
comment: "วุฒิที่ได้รับ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn(
name: "SubDistrictId",
table: "CMSCandidates",
type: "char(36)",
nullable: true,
comment: "Id ตำบล",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "ProvinceId",
table: "CMSCandidates",
type: "char(36)",
nullable: true,
comment: "Id จังหวัด",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "DistrictId",
table: "CMSCandidates",
type: "char(36)",
nullable: true,
comment: "Id อำเภอ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "Address",
table: "CMSCandidates",
type: "longtext",
nullable: true,
comment: "ที่อยู่ปัจจุบัน",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "ที่อยู่")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "DistrictName",
table: "CMSCandidates",
type: "longtext",
nullable: true,
comment: "อำเภอ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "ProvinceName",
table: "CMSCandidates",
type: "longtext",
nullable: true,
comment: "จังหวัด")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "SubDistrictName",
table: "CMSCandidates",
type: "longtext",
nullable: true,
comment: "ตำบล")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn(
name: "RelationshipId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id ศาสนา",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "RegistSubDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id ตำบลที่อยู่ตามทะเบียนบ้าน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "RegistProvinceId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id จังหวัดที่อยู่ตามทะเบียนบ้าน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "RegistDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id อำเภอที่อยู่ตามทะเบียนบ้าน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "PrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id คำนำหน้าชื่อ",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "MotherPrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id คำนำหน้าชื่อมารดา",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "MarryPrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id คำนำหน้าชื่อคู่สมรส",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "FatherPrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id คำนำหน้าชื่อบิดา",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CurrentSubDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id ตำบลที่อยู่ปัจจุบัน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CurrentProvinceId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id จังหวัดที่อยู่ปัจจุบัน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CurrentDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id อำเภอที่อยู่ปัจจุบัน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CitizenProvinceId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id จังหวัดที่ออกบัตรประชาชน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CitizenDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
comment: "Id เขตที่ออกบัตรประชาชน",
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true)
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn(
name: "CitizenDistrictName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "เขตที่ออกบัตรประชาชน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "CitizenProvinceName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "จังหวัดที่ออกบัตรประชาชน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "CurrentDistrictName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "อำเภอที่อยู่ปัจจุบัน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "CurrentProvinceName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "จังหวัดที่อยู่ปัจจุบัน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "CurrentSubDistrictName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "ตำบลที่อยู่ปัจจุบัน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "FatherPrefixName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "คำนำหน้าชื่อบิดา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "MarryPrefixName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "คำนำหน้าชื่อคู่สมรส")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "MotherPrefixName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "คำนำหน้าชื่อมารดา")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "PrefixName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "คำนำหน้าชื่อ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "RegistDistrictName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "อำเภอที่อยู่ตามทะเบียนบ้าน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "RegistProvinceName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "จังหวัดที่อยู่ตามทะเบียนบ้าน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "RegistSubDistrictName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "ตำบลที่อยู่ตามทะเบียนบ้าน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn(
name: "RelationshipName",
table: "Candidates",
type: "longtext",
nullable: true,
comment: "ศาสนา")
.Annotation("MySql:CharSet", "utf8mb4");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EducationLevelName",
table: "Educations");
migrationBuilder.DropColumn(
name: "DistrictName",
table: "CMSCandidates");
migrationBuilder.DropColumn(
name: "ProvinceName",
table: "CMSCandidates");
migrationBuilder.DropColumn(
name: "SubDistrictName",
table: "CMSCandidates");
migrationBuilder.DropColumn(
name: "CitizenDistrictName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "CitizenProvinceName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "CurrentDistrictName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "CurrentProvinceName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "CurrentSubDistrictName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "FatherPrefixName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "MarryPrefixName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "MotherPrefixName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "PrefixName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "RegistDistrictName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "RegistProvinceName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "RegistSubDistrictName",
table: "Candidates");
migrationBuilder.DropColumn(
name: "RelationshipName",
table: "Candidates");
migrationBuilder.AlterColumn(
name: "EducationLevelId",
table: "Educations",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Idวุฒิที่ได้รับ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "SubDistrictId",
table: "CMSCandidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id ตำบล")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "ProvinceId",
table: "CMSCandidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id จังหวัด")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "DistrictId",
table: "CMSCandidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id อำเภอ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "Address",
table: "CMSCandidates",
type: "longtext",
nullable: true,
comment: "ที่อยู่",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "ที่อยู่ปัจจุบัน")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn(
name: "RelationshipId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id ศาสนา")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "RegistSubDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id ตำบลที่อยู่ตามทะเบียนบ้าน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "RegistProvinceId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id จังหวัดที่อยู่ตามทะเบียนบ้าน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "RegistDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id อำเภอที่อยู่ตามทะเบียนบ้าน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "PrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id คำนำหน้าชื่อ")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "MotherPrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id คำนำหน้าชื่อมารดา")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "MarryPrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id คำนำหน้าชื่อคู่สมรส")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "FatherPrefixId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id คำนำหน้าชื่อบิดา")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CurrentSubDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id ตำบลที่อยู่ปัจจุบัน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CurrentProvinceId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id จังหวัดที่อยู่ปัจจุบัน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CurrentDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id อำเภอที่อยู่ปัจจุบัน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CitizenProvinceId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id จังหวัดที่ออกบัตรประชาชน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn(
name: "CitizenDistrictId",
table: "Candidates",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci",
oldClrType: typeof(Guid),
oldType: "char(36)",
oldNullable: true,
oldComment: "Id เขตที่ออกบัตรประชาชน")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.CreateTable(
name: "EducationLevels",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ระดับการศึกษา")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_EducationLevels", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Prefixes",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
Name = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "รายละเอียดคำนำหน้า")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Prefixes", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Provinces",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
Name = table.Column(type: "varchar(150)", maxLength: 150, nullable: false, comment: "จังหวัด")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Provinces", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Relationships",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
Name = table.Column(type: "varchar(50)", maxLength: 50, nullable: false, comment: "ชื่อความสัมพันธ์")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Relationships", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Religions",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
Name = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ศาสนา")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Religions", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Districts",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
Name = table.Column(type: "varchar(150)", maxLength: 150, nullable: false, comment: "เขต/อำเภอ")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
ProvinceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_Districts", x => x.Id);
table.ForeignKey(
name: "FK_Districts_Provinces_ProvinceId",
column: x => x.ProvinceId,
principalTable: "Provinces",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "SubDistricts",
columns: table => new
{
Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
Name = table.Column(type: "varchar(150)", maxLength: 150, nullable: false, comment: "เขต/อำเภอ")
.Annotation("MySql:CharSet", "utf8mb4"),
ZipCode = table.Column(type: "varchar(10)", maxLength: 10, nullable: false, comment: "รหัสไปรษณีย์")
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column(type: "tinyint(1)", nullable: false, comment: "สถานะการใช้งาน"),
CreatedAt = table.Column(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
DistrictId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_SubDistricts", x => x.Id);
table.ForeignKey(
name: "FK_SubDistricts_Districts_DistrictId",
column: x => x.DistrictId,
principalTable: "Districts",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_Educations_EducationLevelId",
table: "Educations",
column: "EducationLevelId");
migrationBuilder.CreateIndex(
name: "IX_CMSCandidates_DistrictId",
table: "CMSCandidates",
column: "DistrictId");
migrationBuilder.CreateIndex(
name: "IX_CMSCandidates_ProvinceId",
table: "CMSCandidates",
column: "ProvinceId");
migrationBuilder.CreateIndex(
name: "IX_CMSCandidates_SubDistrictId",
table: "CMSCandidates",
column: "SubDistrictId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_CitizenDistrictId",
table: "Candidates",
column: "CitizenDistrictId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_CitizenProvinceId",
table: "Candidates",
column: "CitizenProvinceId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_CurrentDistrictId",
table: "Candidates",
column: "CurrentDistrictId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_CurrentProvinceId",
table: "Candidates",
column: "CurrentProvinceId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_CurrentSubDistrictId",
table: "Candidates",
column: "CurrentSubDistrictId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_FatherPrefixId",
table: "Candidates",
column: "FatherPrefixId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_MarryPrefixId",
table: "Candidates",
column: "MarryPrefixId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_MotherPrefixId",
table: "Candidates",
column: "MotherPrefixId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_PrefixId",
table: "Candidates",
column: "PrefixId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_RegistDistrictId",
table: "Candidates",
column: "RegistDistrictId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_RegistProvinceId",
table: "Candidates",
column: "RegistProvinceId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_RegistSubDistrictId",
table: "Candidates",
column: "RegistSubDistrictId");
migrationBuilder.CreateIndex(
name: "IX_Candidates_RelationshipId",
table: "Candidates",
column: "RelationshipId");
migrationBuilder.CreateIndex(
name: "IX_Districts_ProvinceId",
table: "Districts",
column: "ProvinceId");
migrationBuilder.CreateIndex(
name: "IX_SubDistricts_DistrictId",
table: "SubDistricts",
column: "DistrictId");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Districts_CitizenDistrictId",
table: "Candidates",
column: "CitizenDistrictId",
principalTable: "Districts",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Districts_CurrentDistrictId",
table: "Candidates",
column: "CurrentDistrictId",
principalTable: "Districts",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Districts_RegistDistrictId",
table: "Candidates",
column: "RegistDistrictId",
principalTable: "Districts",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Prefixes_FatherPrefixId",
table: "Candidates",
column: "FatherPrefixId",
principalTable: "Prefixes",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Prefixes_MarryPrefixId",
table: "Candidates",
column: "MarryPrefixId",
principalTable: "Prefixes",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Prefixes_MotherPrefixId",
table: "Candidates",
column: "MotherPrefixId",
principalTable: "Prefixes",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Prefixes_PrefixId",
table: "Candidates",
column: "PrefixId",
principalTable: "Prefixes",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Provinces_CitizenProvinceId",
table: "Candidates",
column: "CitizenProvinceId",
principalTable: "Provinces",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Provinces_CurrentProvinceId",
table: "Candidates",
column: "CurrentProvinceId",
principalTable: "Provinces",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Provinces_RegistProvinceId",
table: "Candidates",
column: "RegistProvinceId",
principalTable: "Provinces",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_Relationships_RelationshipId",
table: "Candidates",
column: "RelationshipId",
principalTable: "Relationships",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_SubDistricts_CurrentSubDistrictId",
table: "Candidates",
column: "CurrentSubDistrictId",
principalTable: "SubDistricts",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Candidates_SubDistricts_RegistSubDistrictId",
table: "Candidates",
column: "RegistSubDistrictId",
principalTable: "SubDistricts",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_CMSCandidates_Districts_DistrictId",
table: "CMSCandidates",
column: "DistrictId",
principalTable: "Districts",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_CMSCandidates_Provinces_ProvinceId",
table: "CMSCandidates",
column: "ProvinceId",
principalTable: "Provinces",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_CMSCandidates_SubDistricts_SubDistrictId",
table: "CMSCandidates",
column: "SubDistrictId",
principalTable: "SubDistricts",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Educations_EducationLevels_EducationLevelId",
table: "Educations",
column: "EducationLevelId",
principalTable: "EducationLevels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}