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

namespace JSMR.Infrastructure.Data.Configuration;

public sealed class TagConfiguration : IEntityTypeConfiguration<Tag>
{
    public void Configure(EntityTypeBuilder<Tag> builder)
    {
        builder.ToTable("Tags");
        builder.HasKey(x => x.TagId);

        builder.Property(x => x.Name).IsRequired().HasMaxLength(128);

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