ApiPurchaseConfiguration.cs 1.6 KB

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