Files
hrynco-notification-service/HrynCo.NotificationService.DAL.EF/Configurations/EmailChannelEntityConfiguration.cs
T
agrynco 1631786ce2 feat(push): add service-owned firebase channels and delivery
Add push contracts, provider delivery and channel diagnostics. Link email channels to services and document migration and validation.

Ref: IT-1074
2026-10-24 12:31:35 +03:00

42 lines
1.6 KiB
C#

using HrynCo.NotificationService.DAL.EF.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace HrynCo.NotificationService.DAL.EF.Configurations;
internal class EmailChannelEntityConfiguration : IEntityTypeConfiguration<EmailChannelEntity>
{
public void Configure(EntityTypeBuilder<EmailChannelEntity> builder)
{
builder.ToTable("email_channels");
builder.HasKey(x => x.Id);
builder.Property(x => x.Id).HasColumnName("id");
builder.Property(x => x.ServiceId).HasColumnName("service_id").IsRequired();
builder.HasOne(x => x.Service).WithMany().HasForeignKey(x => x.ServiceId)
.OnDelete(DeleteBehavior.Restrict);
builder.HasIndex(x => new { x.ServiceId, x.Priority });
builder.Property(x => x.Priority).HasColumnName("priority");
builder.Property(x => x.EmailChannelType).HasColumnName("provider_type");
builder.Property(x => x.SettingsJson)
.HasColumnName("settings")
.HasColumnType("jsonb")
.IsRequired();
builder.Property(x => x.DailyLimit).HasColumnName("daily_limit");
builder.Property(x => x.MonthlyLimit).HasColumnName("monthly_limit");
builder.Property(x => x.WarnThresholdPercent).HasColumnName("warn_threshold_percent");
builder.Property(x => x.IsActive).HasColumnName("is_active");
builder.Property(x => x.Created).HasColumnName("created");
builder.Property(x => x.Updated).HasColumnName("updated");
builder.HasMany(x => x.UsageRecords)
.WithOne()
.HasForeignKey(u => u.ProviderId);
}
}