using Domain.Entities.Paper; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Infrastructure.Persistence.Configurations.Paper; public sealed class PaperLedgerConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.HasOne(x => x.Account).WithMany().HasForeignKey(x => x.AccountID).OnDelete(DeleteBehavior.Cascade); builder.HasIndex(x => new { x.AccountID, x.CreatedAt }).IsDescending(false, true); builder.ToTable(nameof(PaperLedger), t => t.HasComment("모의투자 입출금 감사 원장")); builder.HasKey(x => x.ID); builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK"); builder.Property(x => x.AccountID).IsRequired().HasComment("계좌 ID"); builder.Property(x => x.Type).HasConversion().IsRequired().HasComment("유형 (1=입금, 2=출금)"); builder.Property(x => x.TokenAmount).HasPrecision(18, 0).IsRequired().HasComment("이동 토큰"); builder.Property(x => x.UnitsDelta).HasPrecision(18, 8).IsRequired().HasComment("좌수 변화"); builder.Property(x => x.WalletTxRefID).HasMaxLength(100).HasComment("연결 지갑 거래 RefID"); builder.Property(x => x.BalanceAfter).HasPrecision(18, 0).IsRequired().HasComment("이동 후 자유 토큰 잔액"); builder.Property(x => x.CreatedAt).IsRequired(); } }