refactor: rename UserWalletChangeLog→UserWalletHistory, add History interceptor & migration
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m11s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 9m11s
- Rename UserWalletChangeLog to UserWalletHistory across 54+ files (entities, configs, DTOs, commands, queries, protos, services) - Rename 34 files and 11 directories accordingly - Rename proto file userwalletchangelog.proto → userwallethistory.proto - Add IHasHistory<T> generic interface for history auto-tracking - Implement IHasHistory<PackageHistory> on Package entity - Add HistoryTrackingSaveChangesInterceptor (reflection-based, auto-fills Old* values from OriginalValues) - Wire interceptor in DI and ApplicationDbContext - Add EF migration Q27_HistoryTables_And_RenameWalletHistory: * RenameTable UserWalletChangeLogs → UserWalletHistories (preserves data) * Rename PK, FK constraints and indexes via sp_rename * CreateTable ClubMembershipCycleHistories + PackageHistories
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
using CMSMicroservice.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
namespace CMSMicroservice.Infrastructure.Persistence.Configurations;
|
||||
//آدرس کاربر
|
||||
public class UserWalletHistoryConfiguration : IEntityTypeConfiguration<UserWalletHistory>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<UserWalletHistory> builder)
|
||||
{
|
||||
builder.HasQueryFilter(p => !p.IsDeleted);
|
||||
builder.Ignore(entity => entity.DomainEvents);
|
||||
builder.HasKey(entity => entity.Id);
|
||||
builder.Property(entity => entity.Id).UseIdentityColumn();
|
||||
builder
|
||||
.HasOne(entity => entity.Wallet)
|
||||
.WithMany(entity => entity.UserWalletHistories)
|
||||
.HasForeignKey(entity => entity.WalletId)
|
||||
.IsRequired(true);
|
||||
builder.Property(entity => entity.CurrentBalance).IsRequired(true);
|
||||
builder.Property(entity => entity.ChangeValue).IsRequired(true);
|
||||
builder.Property(entity => entity.CurrentNetworkBalance).IsRequired(true);
|
||||
builder.Property(entity => entity.ChangeNerworkValue).IsRequired(true);
|
||||
builder.Property(entity => entity.IsIncrease).IsRequired(true);
|
||||
builder.Property(entity => entity.RefrenceId).IsRequired(false);
|
||||
builder.Property(entity => entity.PackageId).IsRequired(false);
|
||||
|
||||
// رابطه با Package (nullable)
|
||||
builder.HasOne(entity => entity.Package)
|
||||
.WithMany()
|
||||
.HasForeignKey(entity => entity.PackageId)
|
||||
.IsRequired(false)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user