hrms-api-backend/BMA.EHR.Infrastructure/Migrations/20230823060057_add table InsigniaNote.cs

207 lines
14 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class addtableInsigniaNote : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "InsigniaNotes",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Year = table.Column<int>(type: "int", nullable: false),
StartDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
EndDate = table.Column<DateTime>(type: "datetime(6)", nullable: false),
Amount = table.Column<int>(type: "int", maxLength: 50, nullable: false),
ReliefDocId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ราบการยื่นขอ")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaNotes", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaNotes_Documents_ReliefDocId",
column: x => x.ReliefDocId,
principalTable: "Documents",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "InsigniaNoteDocs",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
DocumentId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
Reason = table.Column<string>(type: "longtext", nullable: true, comment: "หมายเหตุ")
.Annotation("MySql:CharSet", "utf8mb4"),
InsigniaNoteId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaNoteDocs", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaNoteDocs_Documents_DocumentId",
column: x => x.DocumentId,
principalTable: "Documents",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaNoteDocs_InsigniaNotes_InsigniaNoteId",
column: x => x.InsigniaNoteId,
principalTable: "InsigniaNotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "InsigniaNoteProfiles",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
RequestDate = table.Column<DateTime>(type: "datetime(6)", nullable: true),
Salary = table.Column<double>(type: "double", nullable: true),
IsApprove = table.Column<bool>(type: "tinyint(1)", nullable: false),
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะตำแหน่งที่ยื่นขอ")
.Annotation("MySql:CharSet", "utf8mb4"),
Issue = table.Column<string>(type: "longtext", nullable: true, comment: "หมายเลขประกาศนียบัตรกำกับเครื่องราชฯ")
.Annotation("MySql:CharSet", "utf8mb4"),
DateReceive = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่ได้รับพระราชทานเครื่องราชฯ"),
OrganizationOrganizationSendId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Date = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่"),
VolumeNo = table.Column<string>(type: "longtext", nullable: true, comment: "เล่มที่")
.Annotation("MySql:CharSet", "utf8mb4"),
Section = table.Column<string>(type: "longtext", nullable: true, comment: "ตอนที่")
.Annotation("MySql:CharSet", "utf8mb4"),
Page = table.Column<string>(type: "longtext", nullable: true, comment: "หน้าที่")
.Annotation("MySql:CharSet", "utf8mb4"),
No = table.Column<string>(type: "longtext", nullable: true, comment: "ลำดับที่")
.Annotation("MySql:CharSet", "utf8mb4"),
DatePayment = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันที่จ่ายใบกำกับ"),
TypePayment = table.Column<string>(type: "longtext", nullable: true, comment: "รูปแบบการจ่าย")
.Annotation("MySql:CharSet", "utf8mb4"),
Address = table.Column<string>(type: "longtext", nullable: true, comment: "ที่อยู่ที่จ่าย")
.Annotation("MySql:CharSet", "utf8mb4"),
ProfileId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
RequestInsigniaId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
InsigniaNoteId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_InsigniaNoteProfiles", x => x.Id);
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_InsigniaNotes_InsigniaNoteId",
column: x => x.InsigniaNoteId,
principalTable: "InsigniaNotes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_Insignias_RequestInsigniaId",
column: x => x.RequestInsigniaId,
principalTable: "Insignias",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_OrganizationOrganizations_OrganizationO~",
column: x => x.OrganizationOrganizationSendId,
principalTable: "OrganizationOrganizations",
principalColumn: "Id");
table.ForeignKey(
name: "FK_InsigniaNoteProfiles_Profiles_ProfileId",
column: x => x.ProfileId,
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteDocs_DocumentId",
table: "InsigniaNoteDocs",
column: "DocumentId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteDocs_InsigniaNoteId",
table: "InsigniaNoteDocs",
column: "InsigniaNoteId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_InsigniaNoteId",
table: "InsigniaNoteProfiles",
column: "InsigniaNoteId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_OrganizationOrganizationSendId",
table: "InsigniaNoteProfiles",
column: "OrganizationOrganizationSendId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_ProfileId",
table: "InsigniaNoteProfiles",
column: "ProfileId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNoteProfiles_RequestInsigniaId",
table: "InsigniaNoteProfiles",
column: "RequestInsigniaId");
migrationBuilder.CreateIndex(
name: "IX_InsigniaNotes_ReliefDocId",
table: "InsigniaNotes",
column: "ReliefDocId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "InsigniaNoteDocs");
migrationBuilder.DropTable(
name: "InsigniaNoteProfiles");
migrationBuilder.DropTable(
name: "InsigniaNotes");
}
}
}