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

namespace CartWise.Infrastructure.Data.Configurations;

public class BrandConfiguration : IEntityTypeConfiguration<Brand>
{
    public void Configure(EntityTypeBuilder<Brand> builder)
    {
        builder.HasKey(b => b.BrandId);

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

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

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