using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; public class OutboxEventConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("outbox_events"); builder.HasKey(o => o.Id); builder.Property(o => o.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()"); builder.Property(o => o.Topic).HasColumnName("topic").HasMaxLength(200).IsRequired(); builder.Property(o => o.Payload).HasColumnName("payload").HasColumnType("jsonb").IsRequired(); builder.Property(o => o.PartitionKey).HasColumnName("partition_key").HasMaxLength(36); builder.Property(o => o.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()"); builder.Property(o => o.ProcessedAt).HasColumnName("processed_at"); builder.Property(o => o.RetryCount).HasColumnName("retry_count").HasDefaultValue(0); builder.Property(o => o.LastError).HasColumnName("last_error"); builder.Property(o => o.FailedAt).HasColumnName("failed_at"); builder.HasIndex(o => o.CreatedAt) .HasFilter("processed_at IS NULL AND failed_at IS NULL"); } }