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

namespace SolutionErp.Infrastructure.Persistence.Configurations;

// EF Mig 35 G-H2 (S34) — Ca làm việc. Catalog standalone.
public class ShiftPatternConfiguration : IEntityTypeConfiguration<ShiftPattern>
{
    public void Configure(EntityTypeBuilder<ShiftPattern> e)
    {
        e.ToTable("ShiftPatterns");

        e.Property(x => x.Code).HasMaxLength(20).IsRequired();
        e.Property(x => x.Name).HasMaxLength(200).IsRequired();
        e.Property(x => x.WorkDays).HasMaxLength(100).IsRequired();   // "Mon,Tue,Wed,Thu,Fri"
        e.Property(x => x.Description).HasMaxLength(500);

        e.HasIndex(x => x.Code).IsUnique().HasFilter("[IsDeleted] = 0");   // Mig 45 (S51 gotcha #57) — soft-deleted slot reusable, khớp handler !IsDeleted
    }
}
