| 123456789101112131415161718192021222324252627 |
- using Domain.Entities.Donations;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- namespace Infrastructure.Persistence.Configurations.Donations;
- public sealed class DonorChannelStatsConfiguration : IEntityTypeConfiguration<DonorChannelStats>
- {
- public void Configure(EntityTypeBuilder<DonorChannelStats> builder)
- {
- builder.HasOne(x => x.Donor).WithMany().HasForeignKey(x => x.DonorMemberID).OnDelete(DeleteBehavior.NoAction);
- builder.HasOne(x => x.Channel).WithMany().HasForeignKey(x => x.ChannelID).OnDelete(DeleteBehavior.NoAction);
- builder.ToTable(nameof(DonorChannelStats), x => x.HasComment("후원자×채널 누적 후원 (칭호 획득 판정용)"));
- builder.HasKey(x => new { x.DonorMemberID, x.ChannelID });
- builder.Property(x => x.DonorMemberID).HasComment("후원자 회원 ID");
- builder.Property(x => x.ChannelID).HasComment("채널 ID");
- builder.Property(x => x.CumulativeAmount).IsRequired().HasComment("누적 후원 금액");
- builder.Property(x => x.DonationCount).IsRequired().HasComment("후원 횟수");
- builder.Property(x => x.FirstDonatedAt).HasComment("첫 후원 일시");
- builder.Property(x => x.LastDonatedAt).HasComment("마지막 후원 일시");
- builder.Property(x => x.UpdatedAt).HasComment("수정 일시");
- builder.Property(x => x.CreatedAt).IsRequired().HasComment("생성 일시");
- builder.HasIndex(x => new { x.ChannelID, x.CumulativeAmount }).IsDescending(false, true);
- }
- }
|