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

public class ReplicaAlertThresholdConfiguration : IEntityTypeConfiguration<ReplicaAlertThreshold>
{
    public void Configure(EntityTypeBuilder<ReplicaAlertThreshold> builder)
    {
        builder.ToTable("alert_thresholds");
        builder.HasKey(t => t.Id);
        builder.Property(t => t.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
        builder.Property(t => t.ObservationCode).HasColumnName("observation_code").HasMaxLength(50).IsRequired();
        builder.Property(t => t.DisplayName).HasColumnName("display_name").HasMaxLength(200).IsRequired();
        builder.Property(t => t.Unit).HasColumnName("unit").HasMaxLength(20).IsRequired();
        builder.Property(t => t.CriticalLow).HasColumnName("critical_low").HasColumnType("decimal(10,3)");
        builder.Property(t => t.WarningLow).HasColumnName("warning_low").HasColumnType("decimal(10,3)");
        builder.Property(t => t.WarningHigh).HasColumnName("warning_high").HasColumnType("decimal(10,3)");
        builder.Property(t => t.CriticalHigh).HasColumnName("critical_high").HasColumnType("decimal(10,3)");
        builder.Property(t => t.SuppressionWindowMinutes).HasColumnName("suppression_window_minutes");
        builder.Property(t => t.SyncedAt).HasColumnName("synced_at");

        builder.HasIndex(t => t.ObservationCode).IsUnique();
    }
}
