ApiPurchaseCancelConfiguration.cs 934 B

12345678910111213141516171819202122
  1. using Domain.Entities.Developers;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.Developers;
  5. public class ApiPurchaseCancelConfiguration : IEntityTypeConfiguration<ApiPurchaseCancel>
  6. {
  7. public void Configure(EntityTypeBuilder<ApiPurchaseCancel> builder)
  8. {
  9. builder.HasIndex(x => x.PurchaseID).IsUnique();
  10. builder.HasIndex(x => x.ApplicationID);
  11. builder.HasIndex(x => x.ChannelID);
  12. builder.HasIndex(x => x.CreatedAt);
  13. builder.ToTable(nameof(ApiPurchaseCancel), x => x.HasComment("API 결제 취소 감사 기록 (1 결제 1 취소)"));
  14. builder.HasKey(x => x.ID);
  15. // 원장(ApiPurchase) 보존 — 취소 기록이 있는 결제는 삭제 불가
  16. builder.HasOne(x => x.Purchase).WithMany().HasForeignKey(x => x.PurchaseID).OnDelete(DeleteBehavior.Restrict);
  17. }
  18. }