using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace BMA.EHR.Infrastructure.Migrations.DisciplineDb { /// public partial class addtableDisciplineInvestigate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropColumn( name: "RejectReason", table: "DisciplineComplaints"); migrationBuilder.AddColumn( name: "Result", table: "DisciplineComplaints", type: "longtext", nullable: true, comment: "ผลการตรวจสอบ") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DisciplineInvestigates", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), 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"), Status = table.Column(type: "longtext", nullable: false, comment: "สถานะเรื่องร้องเรียน มีดังนี้ ใหม่ (NEW), ยุติเรื่อง (STOP), มีมูลส่งไปสืบสวนแล้ว (SEND_INVESTIGATE)") .Annotation("MySql:CharSet", "utf8mb4"), RespondentType = table.Column(type: "longtext", nullable: false, comment: "ผู้ถูกร้องเรียน (PERSON คือ บุคคล, ORGANIZATION คือ หน่วยงาน, BANGKOK คือ กรุงเทพมหานคร)") .Annotation("MySql:CharSet", "utf8mb4"), Title = table.Column(type: "text", nullable: false, comment: "เรื่องที่ร้องเรียน") .Annotation("MySql:CharSet", "utf8mb4"), Description = table.Column(type: "text", nullable: false, comment: "รายละเอียดของเรื่องร้องเรียน") .Annotation("MySql:CharSet", "utf8mb4"), DateReceived = table.Column(type: "datetime(6)", nullable: false, comment: "วันที่รับเรื่อง เป็นวันที่ถือเป็นจุดเริ่มต้นของวินัยนั้น ๆ"), LevelConsideration = table.Column(type: "longtext", nullable: false, comment: "ระดับการพิจารณา 'ยังไม่ระบุ' (NORMAL คือ ปกติ, URGENT คือ ด่วน, VERY_URGENT คือ ด่วนมาก)") .Annotation("MySql:CharSet", "utf8mb4"), DateConsideration = table.Column(type: "datetime(6)", nullable: true, comment: "วันที่กำหนดพิจารณา"), OffenseDetails = table.Column(type: "longtext", nullable: false, comment: "ลักษณะความผิดครั้งแรกจะเป็น 'ยังไม่ระบุ' (NOT_SPECIFIED คือ ยังไม่ระบุ, NOT_DEADLY คือ ไม่ร้ายแรง, DEADLY คือ ร้ายแรง)") .Annotation("MySql:CharSet", "utf8mb4"), DateNotification = table.Column(type: "datetime(6)", nullable: false, comment: "วันแจ้งเตือนล่วงหน้า"), ComplaintFrom = table.Column(type: "longtext", nullable: false, comment: "รับเรื่องร้องเรียนจาก ระบุว่ารับเรื่องมาจากใคร/หน่วยงานไหน (สตง., ปปช., ปปท., จดหมาย, อีเมล, โทรศัพท์, บอกกล่าว)") .Annotation("MySql:CharSet", "utf8mb4"), Appellant = table.Column(type: "longtext", nullable: false, comment: "ผู้ร้องเรียน") .Annotation("MySql:CharSet", "utf8mb4"), ResultComplaint = table.Column(type: "longtext", nullable: true, comment: "ผลการตรวจสอบเรื่องร้องเรียน") .Annotation("MySql:CharSet", "utf8mb4"), Result = table.Column(type: "longtext", nullable: true, comment: "ผลการตรวจสอบ") .Annotation("MySql:CharSet", "utf8mb4"), Organization = table.Column(type: "char(36)", nullable: true, comment: "กรณีหน่วยงานใส่ id ของหน่วยงาน", collation: "ascii_general_ci"), ConsideredAgency = table.Column(type: "char(36)", nullable: false, comment: "หน่วยงานที่พิจารณา จะเปลี่ยนไปตามผู้ถูกร้องดูรายละเอียดด้านล่าง", collation: "ascii_general_ci"), InvestigationDetail = table.Column(type: "longtext", nullable: true, comment: "ลักษณะการสืบสวน (appoint_directors คือ แต่งตั้งกรรมการสืบสวน, secret_investigation คือ สืบสวนทางลับ, other คือ อื่น ๆ)") .Annotation("MySql:CharSet", "utf8mb4"), InvestigationDetailOther = table.Column(type: "longtext", nullable: true, comment: "ลักษณะการสืบสวนกรณีเลือกอื่นๆ") .Annotation("MySql:CharSet", "utf8mb4"), InvestigationDateStart = table.Column(type: "datetime(6)", nullable: true, comment: "วันที่เริ่มการสอบสวน"), InvestigationDateEnd = table.Column(type: "datetime(6)", nullable: true, comment: "วันที่สิ้นสุดการสอบสวน"), InvestigationDescription = table.Column(type: "longtext", nullable: true, comment: "รายละเอียดเกี่ยวกับการสืบสวน") .Annotation("MySql:CharSet", "utf8mb4"), InvestigationStatusResult = table.Column(type: "longtext", nullable: true, comment: "สถานะหรือผลการสืบสวน (not_specified คือ ยังไม่ระบุ, have_cause คือ มีมูล, no_cause คือ ไม่มีมูล") .Annotation("MySql:CharSet", "utf8mb4"), InvestigationCauseText = table.Column(type: "longtext", nullable: true, comment: "กรณีมีมูลต้องเลือกว่า 'ร้ายแรง' หรือ 'ไม่ร้ายแรง'") .Annotation("MySql:CharSet", "utf8mb4"), DisciplineComplaintId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_DisciplineInvestigates", x => x.Id); table.ForeignKey( name: "FK_DisciplineInvestigates_DisciplineComplaints_DisciplineCompla~", column: x => x.DisciplineComplaintId, principalTable: "DisciplineComplaints", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DisciplineInvestigate_Directors", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), 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"), DisciplineDirectorId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), DisciplineComplaintId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), DisciplineInvestigateId = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_DisciplineInvestigate_Directors", x => x.Id); table.ForeignKey( name: "FK_DisciplineInvestigate_Directors_DisciplineComplaints_Discipl~", column: x => x.DisciplineComplaintId, principalTable: "DisciplineComplaints", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DisciplineInvestigate_Directors_DisciplineDirectors_Discipli~", column: x => x.DisciplineDirectorId, principalTable: "DisciplineDirectors", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DisciplineInvestigate_Directors_DisciplineInvestigates_Disci~", column: x => x.DisciplineInvestigateId, principalTable: "DisciplineInvestigates", principalColumn: "Id"); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DisciplineInvestigate_DocComplaints", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), 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"), DocumentId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), DisciplineInvestigateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_DisciplineInvestigate_DocComplaints", x => x.Id); table.ForeignKey( name: "FK_DisciplineInvestigate_DocComplaints_DisciplineInvestigates_D~", column: x => x.DisciplineInvestigateId, principalTable: "DisciplineInvestigates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DisciplineInvestigate_DocComplaints_Documents_DocumentId", column: x => x.DocumentId, principalTable: "Documents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DisciplineInvestigate_Docs", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), 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"), DocumentId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), DisciplineInvestigateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_DisciplineInvestigate_Docs", x => x.Id); table.ForeignKey( name: "FK_DisciplineInvestigate_Docs_DisciplineInvestigates_Discipline~", column: x => x.DisciplineInvestigateId, principalTable: "DisciplineInvestigates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DisciplineInvestigate_Docs_Documents_DocumentId", column: x => x.DocumentId, principalTable: "Documents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "DisciplineInvestigate_Profiles", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"), 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"), PersonId = table.Column(type: "char(36)", nullable: true, comment: "id อ้างอิง profile", collation: "ascii_general_ci"), CitizenId = table.Column(type: "varchar(13)", maxLength: 13, nullable: true, comment: "รหัสบัตรประชาชน") .Annotation("MySql:CharSet", "utf8mb4"), Prefix = table.Column(type: "longtext", nullable: true, comment: "คำนำหน้า") .Annotation("MySql:CharSet", "utf8mb4"), 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"), Organization = table.Column(type: "longtext", nullable: true, comment: "สังกัด") .Annotation("MySql:CharSet", "utf8mb4"), Position = table.Column(type: "longtext", nullable: true, comment: "ตำแหน่ง") .Annotation("MySql:CharSet", "utf8mb4"), PosNo = table.Column(type: "longtext", nullable: true, comment: "เลขที่ตำแหน่ง") .Annotation("MySql:CharSet", "utf8mb4"), PositionLevel = table.Column(type: "longtext", nullable: true, comment: "ระดับ") .Annotation("MySql:CharSet", "utf8mb4"), Salary = table.Column(type: "double", nullable: true, comment: "เงินเดือน"), DisciplineInvestigateId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_DisciplineInvestigate_Profiles", x => x.Id); table.ForeignKey( name: "FK_DisciplineInvestigate_Profiles_DisciplineInvestigates_Discip~", column: x => x.DisciplineInvestigateId, principalTable: "DisciplineInvestigates", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_Directors_DisciplineComplaintId", table: "DisciplineInvestigate_Directors", column: "DisciplineComplaintId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_Directors_DisciplineDirectorId", table: "DisciplineInvestigate_Directors", column: "DisciplineDirectorId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_Directors_DisciplineInvestigateId", table: "DisciplineInvestigate_Directors", column: "DisciplineInvestigateId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_DocComplaints_DisciplineInvestigateId", table: "DisciplineInvestigate_DocComplaints", column: "DisciplineInvestigateId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_DocComplaints_DocumentId", table: "DisciplineInvestigate_DocComplaints", column: "DocumentId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_Docs_DisciplineInvestigateId", table: "DisciplineInvestigate_Docs", column: "DisciplineInvestigateId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_Docs_DocumentId", table: "DisciplineInvestigate_Docs", column: "DocumentId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigate_Profiles_DisciplineInvestigateId", table: "DisciplineInvestigate_Profiles", column: "DisciplineInvestigateId"); migrationBuilder.CreateIndex( name: "IX_DisciplineInvestigates_DisciplineComplaintId", table: "DisciplineInvestigates", column: "DisciplineComplaintId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DisciplineInvestigate_Directors"); migrationBuilder.DropTable( name: "DisciplineInvestigate_DocComplaints"); migrationBuilder.DropTable( name: "DisciplineInvestigate_Docs"); migrationBuilder.DropTable( name: "DisciplineInvestigate_Profiles"); migrationBuilder.DropTable( name: "DisciplineInvestigates"); migrationBuilder.DropColumn( name: "Result", table: "DisciplineComplaints"); migrationBuilder.AddColumn( name: "RejectReason", table: "DisciplineComplaints", type: "longtext", nullable: true, comment: "เหตุผลยุติเรื่อง") .Annotation("MySql:CharSet", "utf8mb4"); } } }