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

namespace JSMR.Infrastructure.Data.Configuration;

public sealed class CircleConfiguration : IEntityTypeConfiguration<Circle>
{
    public void Configure(EntityTypeBuilder<Circle> builder)
    {
        builder.ToTable("Circles");
        builder.HasKey(x => x.CircleId);

        builder.Property(x => x.Name).IsRequired().HasMaxLength(256);
        builder.Property(x => x.MakerId).IsRequired().HasMaxLength(16);

        builder.HasIndex(x => x.Name);
        builder.HasIndex(x => x.MakerId).IsUnique();
        builder.HasIndex(x => x.Favorite);
        builder.HasIndex(x => x.Blacklisted);
        builder.HasIndex(x => x.Spam);
    }
}