using Marathon.Infrastructure.Persistence.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Marathon.Infrastructure.Persistence.Configurations; internal sealed class PlacedBetConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("PlacedBets"); builder.HasKey(b => b.Id); builder.Property(b => b.Id).HasColumnType("TEXT").IsRequired(); builder.Property(b => b.EventCode).HasColumnType("TEXT").IsRequired(); builder.Property(b => b.Scope).HasColumnType("INTEGER").IsRequired(); builder.Property(b => b.PeriodNumber).HasColumnType("INTEGER"); builder.Property(b => b.Type).HasColumnType("INTEGER").IsRequired(); builder.Property(b => b.Side).HasColumnType("INTEGER").IsRequired(); builder.Property(b => b.Value).HasColumnType("TEXT"); builder.Property(b => b.Rate).HasColumnType("TEXT").IsRequired(); builder.Property(b => b.Stake).HasColumnType("TEXT").IsRequired(); builder.Property(b => b.PlacedAt).HasColumnType("TEXT").IsRequired(); builder.Property(b => b.Outcome).HasColumnType("INTEGER").IsRequired(); builder.Property(b => b.Notes).HasColumnType("TEXT"); // EventCode is intentionally NOT a foreign key — the journal is the // user's data and must survive snapshot retention pruning the source // event row. Existence is checked once at insert time by the use case. builder.HasIndex(b => b.EventCode).HasDatabaseName("IX_PlacedBets_EventCode"); builder.HasIndex(b => b.Outcome).HasDatabaseName("IX_PlacedBets_Outcome"); } }