fix: add missing FK migration for EmailChannelUsage -> EmailChannel
- EF model had a pending HasOne/WithMany relationship not in migrations - Adds FK_email_channel_usage_email_channels_provider_id with cascade delete Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+225
@@ -0,0 +1,225 @@
|
|||||||
|
// <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("20260502154249_PendingChanges")]
|
||||||
|
partial class PendingChanges
|
||||||
|
{
|
||||||
|
/// <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.EmailChannelUsageEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelEntity", null)
|
||||||
|
.WithMany("UsageRecords")
|
||||||
|
.HasForeignKey("ProviderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelEntity", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("UsageRecords");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace HrynCo.NotificationService.DAL.EF.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class PendingChanges : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_email_channel_usage_email_channels_provider_id",
|
||||||
|
table: "email_channel_usage",
|
||||||
|
column: "provider_id",
|
||||||
|
principalTable: "email_channels",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_email_channel_usage_email_channels_provider_id",
|
||||||
|
table: "email_channel_usage");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -170,6 +170,15 @@ namespace HrynCo.NotificationService.DAL.EF.Migrations
|
|||||||
b.ToTable("email_templates", (string)null);
|
b.ToTable("email_templates", (string)null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelUsageEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelEntity", null)
|
||||||
|
.WithMany("UsageRecords")
|
||||||
|
.HasForeignKey("ProviderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateEntity", b =>
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateEntity", b =>
|
||||||
{
|
{
|
||||||
b.OwnsMany("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateVariableData", "Variables", b1 =>
|
b.OwnsMany("HrynCo.NotificationService.DAL.EF.Entities.EmailTemplateVariableData", "Variables", b1 =>
|
||||||
@@ -202,6 +211,11 @@ namespace HrynCo.NotificationService.DAL.EF.Migrations
|
|||||||
|
|
||||||
b.Navigation("Variables");
|
b.Navigation("Variables");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("HrynCo.NotificationService.DAL.EF.Entities.EmailChannelEntity", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("UsageRecords");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user