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

namespace SolutionErp.Infrastructure.Persistence.Configurations;

public class ContractClauseConfiguration : IEntityTypeConfiguration<ContractClause>
{
    public void Configure(EntityTypeBuilder<ContractClause> b)
    {
        b.ToTable("ContractClauses");
        b.HasKey(x => x.Id);

        b.Property(x => x.Code).HasMaxLength(50).IsRequired();
        b.Property(x => x.Name).HasMaxLength(200).IsRequired();
        b.Property(x => x.Content).HasColumnType("nvarchar(max)").IsRequired();

        b.HasIndex(x => x.Code).IsUnique();

        b.HasQueryFilter(x => !x.IsDeleted);
    }
}
