26b29d169e
- Directory.Packages.props and Directory.Build.props for central package management - TemplateEntity, ProviderEntity, ProviderUsageEntity (internal to DAL.EF) - TemplateEntityConfiguration: composite unique index (service_name, key, language_code), Variables as JSON column - ProviderEntityConfiguration: settings stored as jsonb, index on (service_name, priority) - ProviderUsageEntityConfiguration: composite unique index (provider_id, date) - All entities map Id column explicitly as 'id' (snake_case) - NotificationDbContext with ApplyConfigurationsFromAssembly Ref: IT-628 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using HrynCo.NotificationService.DAL.EF.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace HrynCo.NotificationService.DAL.EF.Configurations;
|
|
|
|
internal class TemplateEntityConfiguration : IEntityTypeConfiguration<TemplateEntity>
|
|
{
|
|
public void Configure(EntityTypeBuilder<TemplateEntity> builder)
|
|
{
|
|
builder.ToTable("templates");
|
|
|
|
builder.HasKey(x => x.Id);
|
|
builder.Property(x => x.Id).HasColumnName("id");
|
|
|
|
builder.Property(x => x.ServiceName)
|
|
.HasColumnName("service_name")
|
|
.IsRequired()
|
|
.HasMaxLength(100);
|
|
|
|
builder.Property(x => x.Key)
|
|
.HasColumnName("key")
|
|
.IsRequired()
|
|
.HasMaxLength(100);
|
|
|
|
builder.Property(x => x.LanguageCode)
|
|
.HasColumnName("language_code")
|
|
.IsRequired()
|
|
.HasMaxLength(10);
|
|
|
|
builder.HasIndex(x => new { x.ServiceName, x.Key, x.LanguageCode })
|
|
.IsUnique();
|
|
|
|
builder.Property(x => x.Subject)
|
|
.HasColumnName("subject")
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.HtmlBody)
|
|
.HasColumnName("html_body")
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.TextBody)
|
|
.HasColumnName("text_body")
|
|
.IsRequired();
|
|
|
|
builder.Property(x => x.Created).HasColumnName("created");
|
|
builder.Property(x => x.Updated).HasColumnName("updated");
|
|
|
|
builder.OwnsMany(x => x.Variables, v =>
|
|
{
|
|
v.ToJson("variables");
|
|
v.Property(x => x.Name).HasJsonPropertyName("name");
|
|
v.Property(x => x.Required).HasJsonPropertyName("required");
|
|
});
|
|
}
|
|
}
|