feat(email): add durable send ledger
Tracks only idempotency and delivery metadata; recipient, subject, and body are excluded. No provider send path is enabled.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace JobTrackerApi.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddEmailSendAttempts : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
if (ActiveProvider.Contains("MySql", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
migrationBuilder.Sql("""
|
||||
CREATE TABLE `EmailSendAttempts` (
|
||||
`Id` char(36) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,
|
||||
`OwnerUserId` varchar(255) NOT NULL,
|
||||
`JobApplicationId` int NOT NULL,
|
||||
`Provider` varchar(32) NOT NULL,
|
||||
`ClientRequestId` varchar(128) NOT NULL,
|
||||
`PayloadHash` char(64) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL,
|
||||
`Status` varchar(32) NOT NULL,
|
||||
`ProviderMessageId` varchar(256) NULL,
|
||||
`FailureCategory` varchar(64) NULL,
|
||||
`CreatedAtUtc` datetime(6) NOT NULL,
|
||||
`StartedAtUtc` datetime(6) NULL,
|
||||
`CompletedAtUtc` datetime(6) NULL,
|
||||
CONSTRAINT `PK_EmailSendAttempts` PRIMARY KEY (`Id`),
|
||||
CONSTRAINT `FK_EmailSendAttempts_JobApplications_JobApplicationId`
|
||||
FOREIGN KEY (`JobApplicationId`) REFERENCES `JobApplications` (`Id`) ON DELETE CASCADE
|
||||
) CHARACTER SET=utf8mb4;
|
||||
""");
|
||||
}
|
||||
else
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmailSendAttempts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "TEXT", nullable: false),
|
||||
OwnerUserId = table.Column<string>(type: "TEXT", maxLength: 255, nullable: false),
|
||||
JobApplicationId = table.Column<int>(type: "INTEGER", nullable: false),
|
||||
Provider = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
|
||||
ClientRequestId = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
|
||||
PayloadHash = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
|
||||
Status = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
|
||||
ProviderMessageId = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
|
||||
FailureCategory = table.Column<string>(type: "TEXT", maxLength: 64, nullable: true),
|
||||
CreatedAtUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
StartedAtUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
|
||||
CompletedAtUtc = table.Column<DateTime>(type: "TEXT", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmailSendAttempts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_EmailSendAttempts_JobApplications_JobApplicationId",
|
||||
column: x => x.JobApplicationId,
|
||||
principalTable: "JobApplications",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
}
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmailSendAttempts_JobApplicationId",
|
||||
table: "EmailSendAttempts",
|
||||
column: "JobApplicationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmailSendAttempts_OwnerUserId_ClientRequestId",
|
||||
table: "EmailSendAttempts",
|
||||
columns: new[] { "OwnerUserId", "ClientRequestId" },
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmailSendAttempts_OwnerUserId_CreatedAtUtc",
|
||||
table: "EmailSendAttempts",
|
||||
columns: new[] { "OwnerUserId", "CreatedAtUtc" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmailSendAttempts");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1098,6 +1098,69 @@ namespace JobTrackerApi.Migrations
|
||||
b.ToTable("CvVariantVersions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.EmailSendAttempt", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ClientRequestId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("CompletedAtUtc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAtUtc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("FailureCategory")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("JobApplicationId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("OwnerUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("PayloadHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Provider")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ProviderMessageId")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime?>("StartedAtUtc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("JobApplicationId");
|
||||
|
||||
b.HasIndex("OwnerUserId", "ClientRequestId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("OwnerUserId", "CreatedAtUtc");
|
||||
|
||||
b.ToTable("EmailSendAttempts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.GmailConnection", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@@ -2383,6 +2446,17 @@ namespace JobTrackerApi.Migrations
|
||||
b.Navigation("CvVariant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.EmailSendAttempt", b =>
|
||||
{
|
||||
b.HasOne("JobTrackerApi.Models.JobApplication", "JobApplication")
|
||||
.WithMany()
|
||||
.HasForeignKey("JobApplicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("JobApplication");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.InterviewPrepItem", b =>
|
||||
{
|
||||
b.HasOne("JobTrackerApi.Models.JobApplication", "JobApplication")
|
||||
|
||||
Reference in New Issue
Block a user