issue #2551
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 2m58s
All checks were successful
Build & Deploy Leave Service / build (push) Successful in 2m58s
This commit is contained in:
parent
71966eb4e9
commit
2cdae3578e
7 changed files with 1996 additions and 40 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,28 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddUniqueIndexLeaveBeginningProfileIdYearTypeId : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_LeaveBeginnings_ProfileId_LeaveYear_LeaveTypeId",
|
||||
table: "LeaveBeginnings",
|
||||
columns: new[] { "ProfileId", "LeaveYear", "LeaveTypeId" },
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_LeaveBeginnings_ProfileId_LeaveYear_LeaveTypeId",
|
||||
table: "LeaveBeginnings");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -226,6 +226,10 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
|||
|
||||
b.HasIndex("LeaveTypeId");
|
||||
|
||||
b.HasIndex("ProfileId", "LeaveYear", "LeaveTypeId")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("IX_LeaveBeginnings_ProfileId_LeaveYear_LeaveTypeId");
|
||||
|
||||
b.ToTable("LeaveBeginnings");
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -61,5 +61,18 @@ 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue