using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace BMA.EHR.Recurit.Exam.Service.Migrations { /// public partial class createtableCandidate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "PeriodExams", 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"), StartDate = table.Column(type: "datetime(6)", nullable: false, comment: "วันเริ่มสมัครสอบ"), EndDate = table.Column(type: "datetime(6)", nullable: false, comment: "วันสิ้นสุด"), Detail = table.Column(type: "longtext", 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_PeriodExams", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Candidates", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), FirstName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ชื่อจริง") .Annotation("MySql:CharSet", "utf8mb4"), LastName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "นามสกุล") .Annotation("MySql:CharSet", "utf8mb4"), Nationality = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "สัญชาติ") .Annotation("MySql:CharSet", "utf8mb4"), 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"), PeriodExamId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UserId = table.Column(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ผู้สมัคร") .Annotation("MySql:CharSet", "utf8mb4"), PrefixId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), DateOfBirth = table.Column(type: "datetime(6)", maxLength: 40, nullable: true, comment: "วันเกิด"), RelationshipId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), Email = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "อีเมล") .Annotation("MySql:CharSet", "utf8mb4"), CitizenId = table.Column(type: "varchar(20)", maxLength: 20, nullable: false, comment: "เลขประจำตัวประชาชน") .Annotation("MySql:CharSet", "utf8mb4"), CitizenDistrictId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CitizenProvinceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CitizenDate = table.Column(type: "datetime(6)", nullable: true, comment: "วันที่ออกบัตร"), Telephone = table.Column(type: "varchar(20)", maxLength: 20, nullable: false, comment: "โทรศัพท์") .Annotation("MySql:CharSet", "utf8mb4"), MobilePhone = table.Column(type: "varchar(20)", maxLength: 20, nullable: false, comment: "โทรศัพท์มือถือ") .Annotation("MySql:CharSet", "utf8mb4"), Knowledge = table.Column(type: "longtext", nullable: false, comment: "ความสามารถพิเศษ") .Annotation("MySql:CharSet", "utf8mb4"), RegistAddress = table.Column(type: "longtext", nullable: false, comment: "ที่อยู่ตามทะเบียนบ้าน") .Annotation("MySql:CharSet", "utf8mb4"), RegistProvinceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), RegistDistrictId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), RegistSubDistrictId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), RegistZipCode = table.Column(type: "varchar(10)", maxLength: 10, nullable: false, comment: "รหัสไปรษณีย์ที่อยู่ตามทะเบียนบ้าน") .Annotation("MySql:CharSet", "utf8mb4"), RegistSame = table.Column(type: "tinyint(1)", nullable: false, comment: "ที่อยู่ปัจจุบันเหมือนที่อยู่ตามทะเบียนบ้าน"), CurrentAddress = table.Column(type: "longtext", nullable: false, comment: "ที่อยู่ปัจจุบัน") .Annotation("MySql:CharSet", "utf8mb4"), CurrentProvinceId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CurrentDistrictId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CurrentSubDistrictId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), CurrentZipCode = table.Column(type: "varchar(10)", maxLength: 10, nullable: false, comment: "รหัสไปรษณีย์ที่อยู่ปัจจุบัน") .Annotation("MySql:CharSet", "utf8mb4"), Marry = table.Column(type: "tinyint(1)", nullable: false, comment: "คู่สมรส"), MarryPrefixId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), MarryFirstName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ชื่อจริงคู่สมรส") .Annotation("MySql:CharSet", "utf8mb4"), MarryLastName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "นามสกุลคู่สมรส") .Annotation("MySql:CharSet", "utf8mb4"), FatherPrefixId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), FatherFirstName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ชื่อจริงบิดา") .Annotation("MySql:CharSet", "utf8mb4"), FatherLastName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "นามสกุลบิดา") .Annotation("MySql:CharSet", "utf8mb4"), MotherPrefixId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), MotherFirstName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "ชื่อจริงมารดา") .Annotation("MySql:CharSet", "utf8mb4"), MotherLastName = table.Column(type: "varchar(100)", maxLength: 100, nullable: false, comment: "นามสกุลมารดา") .Annotation("MySql:CharSet", "utf8mb4"), OccupationType = table.Column(type: "longtext", nullable: false, comment: "ประเภทอาชีพที่ทำงานมาก่อน") .Annotation("MySql:CharSet", "utf8mb4"), OccupationCompany = table.Column(type: "longtext", nullable: false, comment: "สำนัก/บริษัท บริษัท") .Annotation("MySql:CharSet", "utf8mb4"), OccupationDepartment = table.Column(type: "longtext", nullable: false, comment: "กอง/ฝ่าย บริษัท") .Annotation("MySql:CharSet", "utf8mb4"), OccupationEmail = table.Column(type: "varchar(200)", maxLength: 200, nullable: false, comment: "อีเมล บริษัท") .Annotation("MySql:CharSet", "utf8mb4"), OccupationTelephone = table.Column(type: "varchar(20)", maxLength: 20, nullable: false, comment: "โทรศัพท์ บริษัท") .Annotation("MySql:CharSet", "utf8mb4") }, constraints: table => { table.PrimaryKey("PK_Candidates", x => x.Id); table.ForeignKey( name: "FK_Candidates_Districts_CitizenDistrictId", column: x => x.CitizenDistrictId, principalTable: "Districts", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Districts_CurrentDistrictId", column: x => x.CurrentDistrictId, principalTable: "Districts", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Districts_RegistDistrictId", column: x => x.RegistDistrictId, principalTable: "Districts", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_PeriodExams_PeriodExamId", column: x => x.PeriodExamId, principalTable: "PeriodExams", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Candidates_Prefixes_FatherPrefixId", column: x => x.FatherPrefixId, principalTable: "Prefixes", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Prefixes_MarryPrefixId", column: x => x.MarryPrefixId, principalTable: "Prefixes", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Prefixes_MotherPrefixId", column: x => x.MotherPrefixId, principalTable: "Prefixes", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Prefixes_PrefixId", column: x => x.PrefixId, principalTable: "Prefixes", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Provinces_CitizenProvinceId", column: x => x.CitizenProvinceId, principalTable: "Provinces", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Provinces_CurrentProvinceId", column: x => x.CurrentProvinceId, principalTable: "Provinces", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Provinces_RegistProvinceId", column: x => x.RegistProvinceId, principalTable: "Provinces", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_Relationships_RelationshipId", column: x => x.RelationshipId, principalTable: "Relationships", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_SubDistricts_CurrentSubDistrictId", column: x => x.CurrentSubDistrictId, principalTable: "SubDistricts", principalColumn: "Id"); table.ForeignKey( name: "FK_Candidates_SubDistricts_RegistSubDistrictId", column: x => x.RegistSubDistrictId, principalTable: "SubDistricts", principalColumn: "Id"); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Careers", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), DurationStart = table.Column(type: "datetime(6)", nullable: false, comment: "ระยะเวลาเริ่ม"), DurationEnd = table.Column(type: "datetime(6)", nullable: false, comment: "ระยะเวลาสิ้นสุด"), Name = table.Column(type: "longtext", nullable: false, comment: "สถานที่ทำงาน/ฝึกงาน") .Annotation("MySql:CharSet", "utf8mb4"), Position = table.Column(type: "longtext", nullable: false, comment: "ตำแหน่ง/ลักษณะงาน") .Annotation("MySql:CharSet", "utf8mb4"), Salary = table.Column(type: "int", maxLength: 20, nullable: false, comment: "เงินเดือนสุดท้ายก่อนออก"), Reason = table.Column(type: "longtext", nullable: false, comment: "เหตุผลที่ออก") .Annotation("MySql:CharSet", "utf8mb4"), 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"), CandidateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_Careers", x => x.Id); table.ForeignKey( name: "FK_Careers_Candidates_CandidateId", column: x => x.CandidateId, principalTable: "Candidates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Educations", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), DurationStart = table.Column(type: "datetime(6)", nullable: false, comment: "ระยะเวลาเริ่ม"), DurationEnd = table.Column(type: "datetime(6)", nullable: false, comment: "ระยะเวลาสิ้นสุด"), Name = table.Column(type: "longtext", nullable: false, comment: "ชื่อสถานศึกษา") .Annotation("MySql:CharSet", "utf8mb4"), Major = table.Column(type: "longtext", nullable: false, comment: "สาขาวิชา/วิชาเอก") .Annotation("MySql:CharSet", "utf8mb4"), Scores = table.Column(type: "int", maxLength: 10, 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"), CandidateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), EducationLevelId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_Educations", x => x.Id); table.ForeignKey( name: "FK_Educations_Candidates_CandidateId", column: x => x.CandidateId, principalTable: "Candidates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Educations_EducationLevels_EducationLevelId", column: x => x.EducationLevelId, principalTable: "EducationLevels", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); 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_PeriodExamId", table: "Candidates", column: "PeriodExamId"); 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_Careers_CandidateId", table: "Careers", column: "CandidateId"); migrationBuilder.CreateIndex( name: "IX_Educations_CandidateId", table: "Educations", column: "CandidateId"); migrationBuilder.CreateIndex( name: "IX_Educations_EducationLevelId", table: "Educations", column: "EducationLevelId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Careers"); migrationBuilder.DropTable( name: "Educations"); migrationBuilder.DropTable( name: "Candidates"); migrationBuilder.DropTable( name: "PeriodExams"); } } }