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

namespace SportsDivision.Infrastructure.Data.Configurations;

public class ScoreConfiguration : IEntityTypeConfiguration<Score>
{
    public void Configure(EntityTypeBuilder<Score> builder)
    {
        builder.HasKey(s => s.ScoreId);
        builder.Property(s => s.RawPerformance).HasPrecision(10, 3);
        builder.Property(s => s.RecordedBy).HasMaxLength(450);
        builder.HasOne(s => s.EventRegistration).WithOne(r => r.Score).HasForeignKey<Score>(s => s.EventRegistrationId).OnDelete(DeleteBehavior.Cascade);
    }
}
