using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SolutionErp.Domain.Hrm;

namespace SolutionErp.Infrastructure.Persistence.Configurations;

// 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)
    {
        e.ToTable("Holidays");

        e.Property(x => x.Name).HasMaxLength(200).IsRequired();
        e.Property(x => x.Description).HasMaxLength(500);

        e.HasIndex(x => new { x.Year, x.Date }).IsUnique().HasFilter("[IsDeleted] = 0");
    }
}
