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

public class ClinicalSyncConflictConfiguration : IEntityTypeConfiguration<ClinicalSyncConflict>
{
    public void Configure(EntityTypeBuilder<ClinicalSyncConflict> builder)
    {
        builder.ToTable("clinical_sync_conflicts");
        builder.HasKey(c => c.Id);
        builder.Property(c => c.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
        builder.Property(c => c.BatchId).HasColumnName("batch_id");
        builder.Property(c => c.ClientRef).HasColumnName("client_ref");
        builder.Property(c => c.ItemType).HasColumnName("item_type").HasMaxLength(16);
        builder.Property(c => c.ConflictReason).HasColumnName("conflict_reason").HasMaxLength(500);
        builder.Property(c => c.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");

        builder.HasOne(c => c.Batch)
            .WithMany(b => b.Conflicts)
            .HasForeignKey(c => c.BatchId)
            .OnDelete(DeleteBehavior.Restrict);
    }
}