using Domain.Entities.Developers; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Developers; public class ApiPurchaseConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasIndex(x => new { x.ApplicationID, x.Marketplace, x.OrderID }).IsUnique(); builder.HasIndex(x => new { x.Status, x.ConfirmDueAt }); builder.HasIndex(x => x.ChannelID); builder.HasIndex(x => x.GameID); builder.HasIndex(x => x.CreatedAt); builder.ToTable(nameof(ApiPurchase), x => x.HasComment("게임사 API 결제 보고 원장 (채널 판매 수수료, 14일 보류 후 확정)")); builder.HasKey(x => x.ID); builder.Property(x => x.OrderID).HasMaxLength(255).IsRequired(); builder.Property(x => x.ProductID).HasMaxLength(100); builder.Property(x => x.SubID).HasMaxLength(100); builder.Property(x => x.CommissionRate).HasPrecision(10, 7); // 결제 원장은 감사 보존 대상 — 상위 삭제로 연쇄 삭제되지 않도록 Restrict (Member 경유 다중 cascade 경로 방지 겸용) builder.HasOne(x => x.Application).WithMany().HasForeignKey(x => x.ApplicationID).OnDelete(DeleteBehavior.Restrict); builder.HasOne(x => x.Channel).WithMany().HasForeignKey(x => x.ChannelID).OnDelete(DeleteBehavior.Restrict); builder.HasOne(x => x.Game).WithMany().HasForeignKey(x => x.GameID).OnDelete(DeleteBehavior.Restrict); } }