PaperLedgerConfiguration.cs 1.4 KB

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