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

namespace ERPCore.Infra.Persistence.Configurations;

public sealed class WarehouseConfiguration : IEntityTypeConfiguration<Warehouse>
{
    public void Configure(EntityTypeBuilder<Warehouse> builder)
    {
        builder.ToTable("warehouses");
        builder.HasKey(w => w.WarehouseId);

        builder.Property(w => w.Code).IsRequired().HasMaxLength(50);
        builder.HasIndex(w => w.Code).IsUnique();

        builder.Property(w => w.Name).IsRequired().HasMaxLength(200);
    }
}
