using ItWorx.KnowledgeHub.Domain.Platform; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace ItWorx.KnowledgeHub.Infrastructure.Persistence.Configurations; public sealed class PlatformSettingsConfiguration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("platform_settings", table => table.HasCheckConstraint( "ck_platform_settings_singleton", "\"id\" = '00000000-0000-0000-0000-000000000002'")); builder.HasKey(settings => settings.Id); builder.Property(settings => settings.Id).ValueGeneratedNever(); builder.Property(settings => settings.DisplayName).HasMaxLength(100).IsRequired(); builder.Property(settings => settings.PrimaryLocale).HasMaxLength(20).IsRequired(); builder.Property(settings => settings.TimeZone).HasMaxLength(100).IsRequired(); builder.Property(settings => settings.BackupScheduleDescription).HasMaxLength(200).IsRequired(); builder.Property(settings => settings.Version).IsConcurrencyToken().IsRequired(); builder.Property(settings => settings.UpdatedAt).IsRequired(); builder.ToTable(table => { table.HasCheckConstraint("ck_platform_settings_source_count", "maximum_source_count BETWEEN 1 AND 20"); table.HasCheckConstraint("ck_platform_settings_source_bytes", "maximum_source_bytes BETWEEN 1 AND 104857600"); table.HasCheckConstraint("ck_platform_settings_retry_limit", "failed_retry_limit BETWEEN 1 AND 3"); table.HasCheckConstraint("ck_platform_settings_backup_expectation", "backup_expected_interval_hours BETWEEN 1 AND 8760 AND backup_daily_retention_count BETWEEN 1 AND 365 AND backup_weekly_retention_count BETWEEN 1 AND 104 AND backup_monthly_retention_count BETWEEN 1 AND 120 AND protected_backup_count BETWEEN 1 AND 100 AND restore_verification_max_age_days BETWEEN 1 AND 365"); table.HasCheckConstraint("ck_platform_settings_inventory_freshness", "inventory_warning_after_hours BETWEEN 1 AND 8760"); }); } }