using Deal.Infrastructure.Persistence.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Deal.Infrastructure.Persistence; /// /// EF-конфигурация лимита тенанта: таблица tenant_limits в схеме public. /// public sealed class TenantLimitConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("tenant_limits", "public"); builder.HasKey(x => x.TenantId); builder.Property(x => x.BudgetTokens).IsRequired(); builder.Property(x => x.Period).IsRequired().HasDefaultValue("month"); builder.Property(x => x.PeriodStart).IsRequired(); builder.Property(x => x.UsedTokens).IsRequired(); builder.Property(x => x.Warned80).IsRequired(); builder.Property(x => x.NotifiedExhausted).IsRequired(); builder.Property(x => x.UpdatedAt).IsRequired(); builder.HasOne() .WithMany() .HasForeignKey(x => x.TenantId) .OnDelete(DeleteBehavior.Restrict); } }