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

public class SyncOutboxEntryConfiguration : IEntityTypeConfiguration<SyncOutboxEntry>
{
    public void Configure(EntityTypeBuilder<SyncOutboxEntry> builder)
    {
        builder.ToTable("sync_outbox");
        builder.HasKey(e => e.Id);
        builder.Property(e => e.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
        builder.Property(e => e.BatchId).HasColumnName("batch_id");
        builder.Property(e => e.Status)
            .HasColumnName("status")
            .HasMaxLength(16)
            .HasConversion(
                v => v.ToDbString(),
                v => SyncOutboxStatusExtensions.FromDbString(v))
            .HasDefaultValueSql("'PENDING'")
            .HasSentinel((SyncOutboxStatus)(-1));
        builder.Property(e => e.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
        builder.Property(e => e.SubmittedAt).HasColumnName("submitted_at");
    }
}
