using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace BMA.EHR.Infrastructure.Migrations { /// public partial class updatetableRetirementOtheraddCitizen1 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_Profiles_ProfileId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "Date", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "Organization", table: "RetirementOthers"); migrationBuilder.RenameColumn( name: "ProfileId", table: "RetirementOthers", newName: "PrefixId"); migrationBuilder.RenameIndex( name: "IX_RetirementOthers_ProfileId", table: "RetirementOthers", newName: "IX_RetirementOthers_PrefixId"); migrationBuilder.AlterColumn( name: "Reason", table: "RetirementOthers", type: "longtext", nullable: true, comment: "เหตุผลที่รับย้ายราชการ", oldClrType: typeof(string), oldType: "longtext", oldNullable: true, oldComment: "เหตุผล") .Annotation("MySql:CharSet", "utf8mb4") .OldAnnotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( name: "OrganizationPositionOld", table: "RetirementOthers", type: "longtext", nullable: true, comment: "สังกัดเดิม", oldClrType: typeof(string), oldType: "longtext", oldNullable: true, oldComment: "สังกัด") .Annotation("MySql:CharSet", "utf8mb4") .OldAnnotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "Amount", table: "RetirementOthers", type: "double", nullable: true, comment: "เงินเดือน"); migrationBuilder.AddColumn( name: "BloodGroupId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "CitizenId", table: "RetirementOthers", type: "varchar(20)", maxLength: 20, nullable: false, defaultValue: "", comment: "เลขประจำตัวประชาชน") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "DateOfBirth", table: "RetirementOthers", type: "datetime(6)", maxLength: 40, nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), comment: "วันเกิด"); migrationBuilder.AddColumn( name: "EducationOld", table: "RetirementOthers", type: "longtext", nullable: true, comment: "วุฒิ/สาขาเดิม") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "Firstname", table: "RetirementOthers", type: "longtext", nullable: false, comment: "ชื่อ") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "GenderId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "Lastname", table: "RetirementOthers", type: "longtext", nullable: false, comment: "นามสกุล") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "Nationality", table: "RetirementOthers", type: "varchar(100)", maxLength: 100, nullable: true, comment: "สัญชาติ") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "OrganizationPositionId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "PositionDate", table: "RetirementOthers", type: "datetime(6)", nullable: true, comment: "ดำรงตำแหน่งในระดับปัจจุบันเมื่อ"); migrationBuilder.AddColumn( name: "PositionLevelId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "PositionLineId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "PositionNumberId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "PositionPathId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "PositionPathSideId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "PositionTypeId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "Race", table: "RetirementOthers", type: "varchar(100)", maxLength: 100, nullable: true, comment: "เชื้อชาติ") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "RecruitDate", table: "RetirementOthers", type: "datetime(6)", nullable: true, comment: "วันที่บรรจุ"); migrationBuilder.AddColumn( name: "RelationshipId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "ReligionId", table: "RetirementOthers", type: "char(36)", nullable: true, collation: "ascii_general_ci"); migrationBuilder.AddColumn( name: "TelephoneNumber", table: "RetirementOthers", type: "varchar(50)", maxLength: 50, nullable: true, comment: "เบอร์โทร") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "RetirementOtherDocs", 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"), RetirementOtherId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_RetirementOtherDocs", x => x.Id); table.ForeignKey( name: "FK_RetirementOtherDocs_Documents_DocumentId", column: x => x.DocumentId, principalTable: "Documents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_RetirementOtherDocs_RetirementOthers_RetirementOtherId", column: x => x.RetirementOtherId, principalTable: "RetirementOthers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_BloodGroupId", table: "RetirementOthers", column: "BloodGroupId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_GenderId", table: "RetirementOthers", column: "GenderId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_OrganizationPositionId", table: "RetirementOthers", column: "OrganizationPositionId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_PositionLevelId", table: "RetirementOthers", column: "PositionLevelId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_PositionLineId", table: "RetirementOthers", column: "PositionLineId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_PositionNumberId", table: "RetirementOthers", column: "PositionNumberId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_PositionPathId", table: "RetirementOthers", column: "PositionPathId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_PositionPathSideId", table: "RetirementOthers", column: "PositionPathSideId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_PositionTypeId", table: "RetirementOthers", column: "PositionTypeId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_RelationshipId", table: "RetirementOthers", column: "RelationshipId"); migrationBuilder.CreateIndex( name: "IX_RetirementOthers_ReligionId", table: "RetirementOthers", column: "ReligionId"); migrationBuilder.CreateIndex( name: "IX_RetirementOtherDocs_DocumentId", table: "RetirementOtherDocs", column: "DocumentId"); migrationBuilder.CreateIndex( name: "IX_RetirementOtherDocs_RetirementOtherId", table: "RetirementOtherDocs", column: "RetirementOtherId"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_BloodGroups_BloodGroupId", table: "RetirementOthers", column: "BloodGroupId", principalTable: "BloodGroups", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_Genders_GenderId", table: "RetirementOthers", column: "GenderId", principalTable: "Genders", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_OrganizationPositions_OrganizationPositionId", table: "RetirementOthers", column: "OrganizationPositionId", principalTable: "OrganizationPositions", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_PositionLevels_PositionLevelId", table: "RetirementOthers", column: "PositionLevelId", principalTable: "PositionLevels", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_PositionLines_PositionLineId", table: "RetirementOthers", column: "PositionLineId", principalTable: "PositionLines", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_PositionNumbers_PositionNumberId", table: "RetirementOthers", column: "PositionNumberId", principalTable: "PositionNumbers", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_PositionPathSides_PositionPathSideId", table: "RetirementOthers", column: "PositionPathSideId", principalTable: "PositionPathSides", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_PositionPaths_PositionPathId", table: "RetirementOthers", column: "PositionPathId", principalTable: "PositionPaths", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_PositionTypes_PositionTypeId", table: "RetirementOthers", column: "PositionTypeId", principalTable: "PositionTypes", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_Prefixes_PrefixId", table: "RetirementOthers", column: "PrefixId", principalTable: "Prefixes", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_Relationships_RelationshipId", table: "RetirementOthers", column: "RelationshipId", principalTable: "Relationships", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_Religions_ReligionId", table: "RetirementOthers", column: "ReligionId", principalTable: "Religions", principalColumn: "Id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_BloodGroups_BloodGroupId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_Genders_GenderId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_OrganizationPositions_OrganizationPositionId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_PositionLevels_PositionLevelId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_PositionLines_PositionLineId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_PositionNumbers_PositionNumberId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_PositionPathSides_PositionPathSideId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_PositionPaths_PositionPathId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_PositionTypes_PositionTypeId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_Prefixes_PrefixId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_Relationships_RelationshipId", table: "RetirementOthers"); migrationBuilder.DropForeignKey( name: "FK_RetirementOthers_Religions_ReligionId", table: "RetirementOthers"); migrationBuilder.DropTable( name: "RetirementOtherDocs"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_BloodGroupId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_GenderId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_OrganizationPositionId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_PositionLevelId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_PositionLineId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_PositionNumberId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_PositionPathId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_PositionPathSideId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_PositionTypeId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_RelationshipId", table: "RetirementOthers"); migrationBuilder.DropIndex( name: "IX_RetirementOthers_ReligionId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "Amount", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "BloodGroupId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "CitizenId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "DateOfBirth", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "EducationOld", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "Firstname", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "GenderId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "Lastname", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "Nationality", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "OrganizationPositionId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "PositionDate", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "PositionLevelId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "PositionLineId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "PositionNumberId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "PositionPathId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "PositionPathSideId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "PositionTypeId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "Race", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "RecruitDate", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "RelationshipId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "ReligionId", table: "RetirementOthers"); migrationBuilder.DropColumn( name: "TelephoneNumber", table: "RetirementOthers"); migrationBuilder.RenameColumn( name: "PrefixId", table: "RetirementOthers", newName: "ProfileId"); migrationBuilder.RenameIndex( name: "IX_RetirementOthers_PrefixId", table: "RetirementOthers", newName: "IX_RetirementOthers_ProfileId"); migrationBuilder.AlterColumn( name: "Reason", table: "RetirementOthers", type: "longtext", nullable: true, comment: "เหตุผล", oldClrType: typeof(string), oldType: "longtext", oldNullable: true, oldComment: "เหตุผลที่รับย้ายราชการ") .Annotation("MySql:CharSet", "utf8mb4") .OldAnnotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AlterColumn( name: "OrganizationPositionOld", table: "RetirementOthers", type: "longtext", nullable: true, comment: "สังกัด", oldClrType: typeof(string), oldType: "longtext", oldNullable: true, oldComment: "สังกัดเดิม") .Annotation("MySql:CharSet", "utf8mb4") .OldAnnotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "Date", table: "RetirementOthers", type: "datetime(6)", nullable: true, comment: "ตั้งแต่วันที่"); migrationBuilder.AddColumn( name: "Organization", table: "RetirementOthers", type: "longtext", nullable: true, comment: "หน่วยงานที่อื่นๆไป") .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddForeignKey( name: "FK_RetirementOthers_Profiles_ProfileId", table: "RetirementOthers", column: "ProfileId", principalTable: "Profiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } } }