feat(email): add tenant draft persistence
Add owner-filtered, job-cascading private draft storage with reversible SQLite and MariaDB migration paths. No API or UI exposes draft content yet.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace JobTrackerApi.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddEmailDrafts : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
if (ActiveProvider.Contains("MySql", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
migrationBuilder.Sql("""
|
||||
CREATE TABLE `EmailDrafts` (
|
||||
`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,
|
||||
`To` varchar(320) NOT NULL,
|
||||
`Subject` varchar(998) NOT NULL,
|
||||
`BodyText` longtext NOT NULL,
|
||||
`ThreadId` varchar(512) NULL,
|
||||
`Revision` bigint NOT NULL,
|
||||
`CreatedAtUtc` datetime(6) NOT NULL,
|
||||
`UpdatedAtUtc` datetime(6) NOT NULL,
|
||||
CONSTRAINT `PK_EmailDrafts` PRIMARY KEY (`Id`),
|
||||
CONSTRAINT `FK_EmailDrafts_JobApplications_JobApplicationId`
|
||||
FOREIGN KEY (`JobApplicationId`) REFERENCES `JobApplications` (`Id`) ON DELETE CASCADE
|
||||
) CHARACTER SET=utf8mb4;
|
||||
""");
|
||||
}
|
||||
else
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmailDrafts",
|
||||
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),
|
||||
To = table.Column<string>(type: "TEXT", maxLength: 320, nullable: false),
|
||||
Subject = table.Column<string>(type: "TEXT", maxLength: 998, nullable: false),
|
||||
BodyText = table.Column<string>(type: "TEXT", nullable: false),
|
||||
ThreadId = table.Column<string>(type: "TEXT", maxLength: 512, nullable: true),
|
||||
Revision = table.Column<long>(type: "INTEGER", nullable: false),
|
||||
CreatedAtUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
|
||||
UpdatedAtUtc = table.Column<DateTime>(type: "TEXT", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmailDrafts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_EmailDrafts_JobApplications_JobApplicationId",
|
||||
column: x => x.JobApplicationId,
|
||||
principalTable: "JobApplications",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
}
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmailDrafts_JobApplicationId",
|
||||
table: "EmailDrafts",
|
||||
column: "JobApplicationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmailDrafts_OwnerUserId_JobApplicationId_UpdatedAtUtc",
|
||||
table: "EmailDrafts",
|
||||
columns: new[] { "OwnerUserId", "JobApplicationId", "UpdatedAtUtc" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmailDrafts");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1098,6 +1098,61 @@ namespace JobTrackerApi.Migrations
|
||||
b.ToTable("CvVariantVersions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.EmailDraft", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("BodyText")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("CreatedAtUtc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("JobApplicationId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("OwnerUserId")
|
||||
.IsRequired()
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("Provider")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<long>("Revision")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Subject")
|
||||
.IsRequired()
|
||||
.HasMaxLength(998)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("ThreadId")
|
||||
.HasMaxLength(512)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("To")
|
||||
.IsRequired()
|
||||
.HasMaxLength(320)
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<DateTime>("UpdatedAtUtc")
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("JobApplicationId");
|
||||
|
||||
b.HasIndex("OwnerUserId", "JobApplicationId", "UpdatedAtUtc");
|
||||
|
||||
b.ToTable("EmailDrafts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.EmailSendAttempt", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -2446,6 +2501,17 @@ namespace JobTrackerApi.Migrations
|
||||
b.Navigation("CvVariant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.EmailDraft", b =>
|
||||
{
|
||||
b.HasOne("JobTrackerApi.Models.JobApplication", "JobApplication")
|
||||
.WithMany()
|
||||
.HasForeignKey("JobApplicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("JobApplication");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("JobTrackerApi.Models.EmailSendAttempt", b =>
|
||||
{
|
||||
b.HasOne("JobTrackerApi.Models.JobApplication", "JobApplication")
|
||||
|
||||
Reference in New Issue
Block a user