using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace BMA.EHR.Infrastructure.Migrations.DisciplineDb { /// public partial class updatetableDisciplineComplaint_Profileadddocument : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Profile_Documents_AvatarId", table: "Profile"); migrationBuilder.DropForeignKey( name: "FK_ProfileAvatarHistory_Documents_AvatarFileId", table: "ProfileAvatarHistory"); migrationBuilder.DropForeignKey( name: "FK_ProfileChangeName_Documents_DocumentId", table: "ProfileChangeName"); migrationBuilder.DropForeignKey( name: "FK_ProfileChangeNameHistory_Documents_DocumentId", table: "ProfileChangeNameHistory"); migrationBuilder.DropForeignKey( name: "FK_ProfilePaper_Documents_DocumentId", table: "ProfilePaper"); migrationBuilder.CreateTable( name: "DisciplineComplaint_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"), DisciplineComplaintId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_DisciplineComplaint_Docs", x => x.Id); table.ForeignKey( name: "FK_DisciplineComplaint_Docs_DisciplineComplaints_DisciplineComp~", column: x => x.DisciplineComplaintId, principalTable: "DisciplineComplaints", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_DisciplineComplaint_Docs_Documents_DocumentId", column: x => x.DocumentId, principalTable: "Documents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "Document", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), FileName = table.Column(type: "varchar(255)", maxLength: 255, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), FileSize = table.Column(type: "int", nullable: false), FileType = table.Column(type: "varchar(128)", maxLength: 128, nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Detail = table.Column(type: "text", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ObjectRefId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), CreatedDate = table.Column(type: "datetime(6)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Document", x => x.Id); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_DisciplineComplaint_Docs_DisciplineComplaintId", table: "DisciplineComplaint_Docs", column: "DisciplineComplaintId"); migrationBuilder.CreateIndex( name: "IX_DisciplineComplaint_Docs_DocumentId", table: "DisciplineComplaint_Docs", column: "DocumentId"); migrationBuilder.AddForeignKey( name: "FK_Profile_Document_AvatarId", table: "Profile", column: "AvatarId", principalTable: "Document", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_ProfileAvatarHistory_Document_AvatarFileId", table: "ProfileAvatarHistory", column: "AvatarFileId", principalTable: "Document", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_ProfileChangeName_Document_DocumentId", table: "ProfileChangeName", column: "DocumentId", principalTable: "Document", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_ProfileChangeNameHistory_Document_DocumentId", table: "ProfileChangeNameHistory", column: "DocumentId", principalTable: "Document", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_ProfilePaper_Document_DocumentId", table: "ProfilePaper", column: "DocumentId", principalTable: "Document", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Profile_Document_AvatarId", table: "Profile"); migrationBuilder.DropForeignKey( name: "FK_ProfileAvatarHistory_Document_AvatarFileId", table: "ProfileAvatarHistory"); migrationBuilder.DropForeignKey( name: "FK_ProfileChangeName_Document_DocumentId", table: "ProfileChangeName"); migrationBuilder.DropForeignKey( name: "FK_ProfileChangeNameHistory_Document_DocumentId", table: "ProfileChangeNameHistory"); migrationBuilder.DropForeignKey( name: "FK_ProfilePaper_Document_DocumentId", table: "ProfilePaper"); migrationBuilder.DropTable( name: "DisciplineComplaint_Docs"); migrationBuilder.DropTable( name: "Document"); migrationBuilder.AddForeignKey( name: "FK_Profile_Documents_AvatarId", table: "Profile", column: "AvatarId", principalTable: "Documents", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_ProfileAvatarHistory_Documents_AvatarFileId", table: "ProfileAvatarHistory", column: "AvatarFileId", principalTable: "Documents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_ProfileChangeName_Documents_DocumentId", table: "ProfileChangeName", column: "DocumentId", principalTable: "Documents", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_ProfileChangeNameHistory_Documents_DocumentId", table: "ProfileChangeNameHistory", column: "DocumentId", principalTable: "Documents", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_ProfilePaper_Documents_DocumentId", table: "ProfilePaper", column: "DocumentId", principalTable: "Documents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } } }