fix: 添加 TenantReviewClaim 和 TenantAuditLog 实体的 EF Core 表映射配置

修复 EF Core 使用默认 PascalCase 表名导致的 "relation TenantReviewClaims does not exist" 错误,
将实体映射到正确的 snake_case 表名。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
MSuMshk
2026-02-02 20:31:36 +08:00
parent 6ffcc09c26
commit 874bd799e7

View File

@@ -385,6 +385,8 @@ public class TakeoutAppDbContext(
ConfigureTenantBillingStatement(modelBuilder.Entity<TenantBillingStatement>());
ConfigureTenantSubscriptionHistory(modelBuilder.Entity<TenantSubscriptionHistory>());
ConfigureTenantPayment(modelBuilder.Entity<TenantPayment>());
ConfigureTenantReviewClaim(modelBuilder.Entity<TenantReviewClaim>());
ConfigureTenantAuditLog(modelBuilder.Entity<TenantAuditLog>());
ConfigureMerchant(modelBuilder.Entity<Merchant>());
ConfigureStore(modelBuilder.Entity<Store>());
ConfigureMerchantDocument(modelBuilder.Entity<MerchantDocument>());
@@ -595,6 +597,35 @@ public class TakeoutAppDbContext(
builder.HasIndex(x => x.TenantId);
}
private static void ConfigureTenantReviewClaim(EntityTypeBuilder<TenantReviewClaim> builder)
{
builder.ToTable("tenant_review_claims");
builder.HasKey(x => x.Id);
builder.Property(x => x.TenantId).IsRequired();
builder.Property(x => x.ClaimedBy).IsRequired();
builder.Property(x => x.ClaimedByName).HasMaxLength(128).IsRequired();
builder.Property(x => x.ClaimedAt).IsRequired();
builder.Property(x => x.ReleasedAt);
builder.HasIndex(x => x.TenantId);
builder.HasIndex(x => x.ClaimedBy);
}
private static void ConfigureTenantAuditLog(EntityTypeBuilder<TenantAuditLog> builder)
{
builder.ToTable("tenant_audit_logs");
builder.HasKey(x => x.Id);
builder.Property(x => x.TenantId).IsRequired();
builder.Property(x => x.Action).HasConversion<int>();
builder.Property(x => x.Title).HasMaxLength(128).IsRequired();
builder.Property(x => x.Description).HasMaxLength(512);
builder.Property(x => x.OperatorId);
builder.Property(x => x.OperatorName).HasMaxLength(128);
builder.Property(x => x.PreviousStatus).HasConversion<int?>();
builder.Property(x => x.CurrentStatus).HasConversion<int?>();
builder.HasIndex(x => x.TenantId);
builder.HasIndex(x => new { x.TenantId, x.CreatedAt });
}
private static void ConfigureMerchant(EntityTypeBuilder<Merchant> builder)
{
builder.ToTable("merchants");