| 12345678910111213141516171819202122232425262728293031 |
- using Domain.Entities.Store;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.EntityFrameworkCore.Metadata.Builders;
- namespace Infrastructure.Persistence.Configurations.Store;
- public sealed class CouponConfiguration : IEntityTypeConfiguration<Coupon>
- {
- public void Configure(EntityTypeBuilder<Coupon> builder)
- {
- builder.ToTable(nameof(Coupon), t => t.HasComment("쿠폰 메타 (코드 풀의 상위)"));
- builder.HasKey(x => x.ID);
- builder.HasOne(x => x.Product).WithMany().HasForeignKey(x => x.ProductID).OnDelete(DeleteBehavior.Restrict);
- builder.HasOne(x => x.Game).WithMany().HasForeignKey(x => x.GameID).OnDelete(DeleteBehavior.Restrict);
- builder.Property(x => x.ProductID).IsRequired();
- builder.Property(x => x.GameID).IsRequired().HasComment("게임 ID (필수)");
- builder.Property(x => x.Name).HasMaxLength(200).IsRequired();
- builder.Property(x => x.ExpiresAt);
- builder.Property(x => x.UsagePolicy).HasConversion<int>().IsRequired();
- builder.Property(x => x.GeneratedCount).IsRequired();
- builder.Property(x => x.UsedCount).IsRequired();
- builder.Property(x => x.LowStockThreshold).IsRequired().HasDefaultValue(10);
- builder.Property(x => x.CreatedAt).IsRequired();
- builder.Property(x => x.UpdatedAt);
- builder.HasIndex(x => x.ProductID);
- builder.HasIndex(x => x.GameID);
- }
- }
|