feat: add EF migrations and design-time factory
- Fix EmailEmailTemplateEntityConfiguration -> EmailTemplateEntityConfiguration - Rename tables to match domain: templates->email_templates, providers->email_channels, provider_usage->email_channel_usage - Add NotificationDbContextFactory for design-time migrations tooling - Add InitialCreate migration: email_templates, email_channels, email_channel_usage Ref: IT-628 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ internal class EmailChannelEntityConfiguration : IEntityTypeConfiguration<EmailC
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<EmailChannelEntity> builder)
|
public void Configure(EntityTypeBuilder<EmailChannelEntity> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("providers");
|
builder.ToTable("email_channels");
|
||||||
|
|
||||||
builder.HasKey(x => x.Id);
|
builder.HasKey(x => x.Id);
|
||||||
builder.Property(x => x.Id).HasColumnName("id");
|
builder.Property(x => x.Id).HasColumnName("id");
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ internal class EmailChannelUsageEntityConfiguration : IEntityTypeConfiguration<E
|
|||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<EmailChannelUsageEntity> builder)
|
public void Configure(EntityTypeBuilder<EmailChannelUsageEntity> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("provider_usage");
|
builder.ToTable("email_channel_usage");
|
||||||
|
|
||||||
builder.HasKey(x => x.Id);
|
builder.HasKey(x => x.Id);
|
||||||
builder.Property(x => x.Id).HasColumnName("id");
|
builder.Property(x => x.Id).HasColumnName("id");
|
||||||
|
|||||||
+2
-2
@@ -4,11 +4,11 @@ using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|||||||
|
|
||||||
namespace HrynCo.NotificationService.DAL.EF.Configurations;
|
namespace HrynCo.NotificationService.DAL.EF.Configurations;
|
||||||
|
|
||||||
internal class EmailEmailTemplateEntityConfiguration : IEntityTypeConfiguration<EmailTemplateEntity>
|
internal class EmailTemplateEntityConfiguration : IEntityTypeConfiguration<EmailTemplateEntity>
|
||||||
{
|
{
|
||||||
public void Configure(EntityTypeBuilder<EmailTemplateEntity> builder)
|
public void Configure(EntityTypeBuilder<EmailTemplateEntity> builder)
|
||||||
{
|
{
|
||||||
builder.ToTable("templates");
|
builder.ToTable("email_templates");
|
||||||
|
|
||||||
builder.HasKey(x => x.Id);
|
builder.HasKey(x => x.Id);
|
||||||
builder.Property(x => x.Id).HasColumnName("id");
|
builder.Property(x => x.Id).HasColumnName("id");
|
||||||
|
|||||||
+211
@@ -0,0 +1,211 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using HrynCo.NotificationService.DAL.EF;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace HrynCo.NotificationService.DAL.EF.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(NotificationDbContext))]
|
||||||
|
[Migration("20260501214629_InitialCreate")]
|
||||||
|
partial class InitialCreate
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "9.0.5")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Created")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created");
|
||||||
|
|
||||||
|
b.Property<int?>("DailyLimit")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("daily_limit");
|
||||||
|
|
||||||
|
b.Property<int>("EmailChannelType")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("provider_type");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("is_active");
|
||||||
|
|
||||||
|
b.Property<int?>("MonthlyLimit")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("monthly_limit");
|
||||||
|
|
||||||
|
b.Property<int>("Priority")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("priority");
|
||||||
|
|
||||||
|
b.Property<string>("ServiceName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("service_name");
|
||||||
|
|
||||||
|
b.Property<string>("SettingsJson")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("settings");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Updated")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated");
|
||||||
|
|
||||||
|
b.Property<int>("WarnThresholdPercent")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("warn_threshold_percent");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServiceName", "Priority");
|
||||||
|
|
||||||
|
b.ToTable("email_channels", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelUsageEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Created")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created");
|
||||||
|
|
||||||
|
b.Property<DateOnly>("Date")
|
||||||
|
.HasColumnType("date")
|
||||||
|
.HasColumnName("date");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProviderId")
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("provider_id");
|
||||||
|
|
||||||
|
b.Property<int>("SentCount")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("sent_count");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Updated")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProviderId", "Date")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("email_channel_usage", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Created")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created");
|
||||||
|
|
||||||
|
b.Property<string>("HtmlBody")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("html_body");
|
||||||
|
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("key");
|
||||||
|
|
||||||
|
b.Property<string>("LanguageCode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(10)
|
||||||
|
.HasColumnType("character varying(10)")
|
||||||
|
.HasColumnName("language_code");
|
||||||
|
|
||||||
|
b.Property<string>("ServiceName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("service_name");
|
||||||
|
|
||||||
|
b.Property<string>("Subject")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("subject");
|
||||||
|
|
||||||
|
b.Property<string>("TextBody")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("text_body");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Updated")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServiceName", "Key", "LanguageCode")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("email_templates", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateEntity", b =>
|
||||||
|
{
|
||||||
|
b.OwnsMany("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateVariableData", "Variables", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<Guid>("EmailTemplateEntityId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b1.Property<int>("__synthesizedOrdinal")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b1.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||||
|
|
||||||
|
b1.Property<bool>("Required")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "required");
|
||||||
|
|
||||||
|
b1.HasKey("EmailTemplateEntityId", "__synthesizedOrdinal");
|
||||||
|
|
||||||
|
b1.ToTable("email_templates");
|
||||||
|
|
||||||
|
b1.ToJson("variables");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("EmailTemplateEntityId");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("Variables");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace HrynCo.NotificationService.DAL.EF.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class InitialCreate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "email_channel_usage",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
provider_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
date = table.Column<DateOnly>(type: "date", nullable: false),
|
||||||
|
sent_count = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
created = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
updated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_email_channel_usage", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "email_channels",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
service_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||||
|
priority = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
provider_type = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
settings = table.Column<string>(type: "jsonb", nullable: false),
|
||||||
|
daily_limit = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
monthly_limit = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
warn_threshold_percent = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
is_active = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
created = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
updated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_email_channels", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "email_templates",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
service_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||||
|
key = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
||||||
|
language_code = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
||||||
|
subject = table.Column<string>(type: "text", nullable: false),
|
||||||
|
html_body = table.Column<string>(type: "text", nullable: false),
|
||||||
|
text_body = table.Column<string>(type: "text", nullable: false),
|
||||||
|
created = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
updated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||||
|
variables = table.Column<string>(type: "jsonb", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_email_templates", x => x.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_email_channel_usage_provider_id_date",
|
||||||
|
table: "email_channel_usage",
|
||||||
|
columns: new[] { "provider_id", "date" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_email_channels_service_name_priority",
|
||||||
|
table: "email_channels",
|
||||||
|
columns: new[] { "service_name", "priority" });
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_email_templates_service_name_key_language_code",
|
||||||
|
table: "email_templates",
|
||||||
|
columns: new[] { "service_name", "key", "language_code" },
|
||||||
|
unique: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "email_channel_usage");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "email_channels");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "email_templates");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using HrynCo.NotificationService.DAL.EF;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace HrynCo.NotificationService.DAL.EF.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(NotificationDbContext))]
|
||||||
|
partial class NotificationDbContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "9.0.5")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Created")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created");
|
||||||
|
|
||||||
|
b.Property<int?>("DailyLimit")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("daily_limit");
|
||||||
|
|
||||||
|
b.Property<int>("EmailChannelType")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("provider_type");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("is_active");
|
||||||
|
|
||||||
|
b.Property<int?>("MonthlyLimit")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("monthly_limit");
|
||||||
|
|
||||||
|
b.Property<int>("Priority")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("priority");
|
||||||
|
|
||||||
|
b.Property<string>("ServiceName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("service_name");
|
||||||
|
|
||||||
|
b.Property<string>("SettingsJson")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("settings");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Updated")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated");
|
||||||
|
|
||||||
|
b.Property<int>("WarnThresholdPercent")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("warn_threshold_percent");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServiceName", "Priority");
|
||||||
|
|
||||||
|
b.ToTable("email_channels", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelUsageEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Created")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created");
|
||||||
|
|
||||||
|
b.Property<DateOnly>("Date")
|
||||||
|
.HasColumnType("date")
|
||||||
|
.HasColumnName("date");
|
||||||
|
|
||||||
|
b.Property<Guid>("ProviderId")
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("provider_id");
|
||||||
|
|
||||||
|
b.Property<int>("SentCount")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("sent_count");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Updated")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ProviderId", "Date")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("email_channel_usage", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("Created")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("created");
|
||||||
|
|
||||||
|
b.Property<string>("HtmlBody")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("html_body");
|
||||||
|
|
||||||
|
b.Property<string>("Key")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("key");
|
||||||
|
|
||||||
|
b.Property<string>("LanguageCode")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(10)
|
||||||
|
.HasColumnType("character varying(10)")
|
||||||
|
.HasColumnName("language_code");
|
||||||
|
|
||||||
|
b.Property<string>("ServiceName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("character varying(100)")
|
||||||
|
.HasColumnName("service_name");
|
||||||
|
|
||||||
|
b.Property<string>("Subject")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("subject");
|
||||||
|
|
||||||
|
b.Property<string>("TextBody")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("text_body");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("Updated")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("updated");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ServiceName", "Key", "LanguageCode")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("email_templates", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateEntity", b =>
|
||||||
|
{
|
||||||
|
b.OwnsMany("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateVariableData", "Variables", b1 =>
|
||||||
|
{
|
||||||
|
b1.Property<Guid>("EmailTemplateEntityId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b1.Property<int>("__synthesizedOrdinal")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b1.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "name");
|
||||||
|
|
||||||
|
b1.Property<bool>("Required")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasAnnotation("Relational:JsonPropertyName", "required");
|
||||||
|
|
||||||
|
b1.HasKey("EmailTemplateEntityId", "__synthesizedOrdinal");
|
||||||
|
|
||||||
|
b1.ToTable("email_templates");
|
||||||
|
|
||||||
|
b1.ToJson("variables");
|
||||||
|
|
||||||
|
b1.WithOwner()
|
||||||
|
.HasForeignKey("EmailTemplateEntityId");
|
||||||
|
});
|
||||||
|
|
||||||
|
b.Navigation("Variables");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Design;
|
||||||
|
|
||||||
|
namespace HrynCo.NotificationService.DAL.EF;
|
||||||
|
|
||||||
|
internal sealed class NotificationDbContextFactory : IDesignTimeDbContextFactory<NotificationDbContext>
|
||||||
|
{
|
||||||
|
public NotificationDbContext CreateDbContext(string[] args)
|
||||||
|
{
|
||||||
|
var options = new DbContextOptionsBuilder<NotificationDbContext>()
|
||||||
|
.UseNpgsql("Host=localhost;Port=5432;Database=notification_service;Username=postgres;Password=postgres")
|
||||||
|
.Options;
|
||||||
|
|
||||||
|
return new NotificationDbContext(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user