[CLAUDE] Infra: Mig 43 filter Holiday UNIQUE (Year,Date) by IsDeleted (S45)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 4m19s
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 4m19s
Fix drift surfaced by S45 Holiday coverage tests: DB UNIQUE (Year,Date) was unfiltered while handler checks !IsDeleted -> recreating a holiday on a soft-deleted slot threw DbUpdateException(500). Add .HasFilter("[IsDeleted] = 0") matching the 13x project filtered-unique pattern (Catalogs/Contract/PE/Proposal/Budget/WorkflowApps). Soft-deleted slot now reusable per app intent. Flipped Case 7 to assert success-on-reuse. 181 test PASS.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -4,7 +4,8 @@ using SolutionErp.Domain.Hrm;
|
||||
|
||||
namespace SolutionErp.Infrastructure.Persistence.Configurations;
|
||||
|
||||
// EF Mig 35 G-H2 (S34) — Ngày lễ. UNIQUE composite (Year, Date).
|
||||
// EF Mig 35 G-H2 (S34) — Ngày lễ. UNIQUE composite (Year, Date) filtered WHERE IsDeleted=0
|
||||
// (Mig 43 S45 — soft-deleted slot reusable, khớp app-level !IsDeleted check + pattern Catalogs/Contract/PE).
|
||||
public class HolidayConfiguration : IEntityTypeConfiguration<Holiday>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Holiday> e)
|
||||
@ -14,6 +15,6 @@ public class HolidayConfiguration : IEntityTypeConfiguration<Holiday>
|
||||
e.Property(x => x.Name).HasMaxLength(200).IsRequired();
|
||||
e.Property(x => x.Description).HasMaxLength(500);
|
||||
|
||||
e.HasIndex(x => new { x.Year, x.Date }).IsUnique();
|
||||
e.HasIndex(x => new { x.Year, x.Date }).IsUnique().HasFilter("[IsDeleted] = 0");
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SolutionErp.Infrastructure.Persistence.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FilterHolidayUniqueIndexByIsDeleted : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Holidays_Year_Date",
|
||||
table: "Holidays");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Holidays_Year_Date",
|
||||
table: "Holidays",
|
||||
columns: new[] { "Year", "Date" },
|
||||
unique: true,
|
||||
filter: "[IsDeleted] = 0");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Holidays_Year_Date",
|
||||
table: "Holidays");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Holidays_Year_Date",
|
||||
table: "Holidays",
|
||||
columns: new[] { "Year", "Date" },
|
||||
unique: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2548,7 +2548,8 @@ namespace SolutionErp.Infrastructure.Persistence.Migrations
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Year", "Date")
|
||||
.IsUnique();
|
||||
.IsUnique()
|
||||
.HasFilter("[IsDeleted] = 0");
|
||||
|
||||
b.ToTable("Holidays", (string)null);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user