using CartWise.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CartWise.Infrastructure.Data.Configurations;

public class RetailerConfiguration : IEntityTypeConfiguration<Retailer>
{
    public void Configure(EntityTypeBuilder<Retailer> builder)
    {
        builder.HasKey(r => r.RetailerId);

        builder.Property(r => r.Name)
            .HasMaxLength(160)
            .IsRequired();

        builder.Property(r => r.NormalizedName)
            .HasMaxLength(160)
            .IsRequired();

        builder.HasIndex(r => r.NormalizedName)
            .IsUnique();
    }
}
