Add migration for LeaveProcessJobStatuses table

- Created a new migration to add the LeaveProcessJobStatuses table.
- The table includes fields for job status, timestamps, user information, and error messages.
- Supports tracking of leave process job statuses with relevant metadata.
This commit is contained in:
Suphonchai Phoonsawat 2026-03-30 09:23:13 +07:00
parent d8f1126764
commit c91e6c8030
5 changed files with 1980 additions and 0 deletions

View file

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using BMA.EHR.Domain.Models.Base;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Domain.Models.Leave.TimeAttendants
{
public class LeaveProcessJobStatus: EntityBase
{
[Required, Comment("วันเริ่มต้น")]
public DateTime StartDate { get; set; }
[Required, Comment("วันสิ้นสุด")]
public DateTime EndDate { get; set; }
[Required, Comment("รหัส Root DNA Id")]
public Guid RootDnaId { get; set; } = Guid.Empty;
[Comment("วันเวลาที่สร้างงาน")]
public DateTime CreatedDate { get; set; } = DateTime.Now;
[Comment("วันเวลาที่เริ่มประมวลผล")]
public DateTime? ProcessingDate { get; set; }
[Comment("วันเวลาที่เสร็จสิ้นการประมวลผล")]
public DateTime? CompletedDate { get; set; }
[Required, Comment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED")]
public string Status { get; set; } = "PENDING";
[Comment("ข้อความแสดงข้อผิดพลาด")]
public string? ErrorMessage { get; set; }
}
}

View file

@ -0,0 +1,54 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
{
/// <inheritdoc />
public partial class AddLeaveProcessJobStatus : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "LeaveProcessJobStatuses",
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"),
StartDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "วันเริ่มต้น"),
EndDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "วันสิ้นสุด"),
RootDnaId = table.Column<Guid>(type: "char(36)", nullable: false, comment: "รหัส Root DNA Id", collation: "ascii_general_ci"),
CreatedDate = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "วันเวลาที่สร้างงาน"),
ProcessingDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันเวลาที่เริ่มประมวลผล"),
CompletedDate = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "วันเวลาที่เสร็จสิ้นการประมวลผล"),
Status = table.Column<string>(type: "longtext", nullable: false, comment: "สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED")
.Annotation("MySql:CharSet", "utf8mb4"),
ErrorMessage = table.Column<string>(type: "longtext", nullable: true, comment: "ข้อความแสดงข้อผิดพลาด")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_LeaveProcessJobStatuses", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "LeaveProcessJobStatuses");
}
}
}

View file

@ -1072,6 +1072,91 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
b.ToTable("DutyTimes");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.LeaveProcessJobStatus", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime?>("CompletedDate")
.HasColumnType("datetime(6)")
.HasComment("วันเวลาที่เสร็จสิ้นการประมวลผล");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<DateTime>("CreatedDate")
.HasColumnType("datetime(6)")
.HasComment("วันเวลาที่สร้างงาน");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<DateTime>("EndDate")
.HasColumnType("datetime(6)")
.HasComment("วันสิ้นสุด");
b.Property<string>("ErrorMessage")
.HasColumnType("longtext")
.HasComment("ข้อความแสดงข้อผิดพลาด");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<DateTime?>("ProcessingDate")
.HasColumnType("datetime(6)")
.HasComment("วันเวลาที่เริ่มประมวลผล");
b.Property<Guid>("RootDnaId")
.HasColumnType("char(36)")
.HasComment("รหัส Root DNA Id");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime(6)")
.HasComment("วันเริ่มต้น");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("longtext")
.HasComment("สถานะงาน: PENDING, PROCESSING, COMPLETED, FAILED");
b.HasKey("Id");
b.ToTable("LeaveProcessJobStatuses");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Leave.TimeAttendants.ProcessUserTimeStamp", b =>
{
b.Property<Guid>("Id")

View file

@ -40,6 +40,8 @@ namespace BMA.EHR.Infrastructure.Persistence
#endregion
public DbSet<LeaveProcessJobStatus> LeaveProcessJobStatuses { get; set; }
public LeaveDbContext(DbContextOptions<LeaveDbContext> options) : base(options)
{