using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace CalledIt.DataAccess.Entities.Configuration;

public class CompetitionConfiguration : IEntityTypeConfiguration<CompetitionEntity>
{
    public void Configure(EntityTypeBuilder<CompetitionEntity> builder)
    {
        builder.ToTable("Competitions");

        builder.HasKey(x => x.Id);

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

        builder.HasIndex(x => x.Name)
            .IsUnique();

        builder.Property(x => x.Description)
            .HasMaxLength(500);

        builder.Property(x => x.StartDate);

        builder.Property(x => x.EndDate);
    }
}
