fix #2551 Error
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 2m22s

This commit is contained in:
Suphonchai Phoonsawat 2026-06-19 11:11:46 +07:00
parent 2cdae3578e
commit 6843e3ff3f
4 changed files with 14 additions and 1875 deletions

View file

@ -61,18 +61,5 @@ namespace BMA.EHR.Infrastructure.Persistence
{
base.Entry(entity).State = EntityState.Detached;
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// Composite unique index on the natural key for LeaveBeginning.
// Prevents duplicate rows when concurrent requests (e.g. UI calling /user/check twice)
// race through the get-or-create flow in LeaveBeginningRepository.
modelBuilder.Entity<LeaveBeginning>()
.HasIndex(b => new { b.ProfileId, b.LeaveYear, b.LeaveTypeId })
.HasDatabaseName("IX_LeaveBeginnings_ProfileId_LeaveYear_LeaveTypeId")
.IsUnique();
}
}
}