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

public class ClinicalSiteConfiguration : IEntityTypeConfiguration<ClinicalSite>
{
    public void Configure(EntityTypeBuilder<ClinicalSite> builder)
    {
        builder.ToTable("clinical_sites");
        builder.HasKey(s => s.Id);
        builder.Property(s => s.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
        builder.Property(s => s.SiteCode).HasColumnName("site_code").HasMaxLength(32).IsRequired();
        builder.Property(s => s.Name).HasColumnName("name").HasMaxLength(200).IsRequired();
        builder.Property(s => s.Address).HasColumnName("address");
        builder.Property(s => s.Active).HasColumnName("active").HasDefaultValue(true);
        builder.Property(s => s.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
        builder.HasIndex(s => s.SiteCode).IsUnique();
    }
}
