refactor(db): adopt email settings migration

This commit is contained in:
cesnimda
2026-08-30 16:42:19 +02:00
parent 2d7a51c3fd
commit e47ad1d243
11 changed files with 324 additions and 34 deletions
@@ -1469,25 +1469,6 @@ public static class StartupInitializationExtensions
cmd.ExecuteNonQuery();
}
if (!HasMySqlTable(conn, "SystemEmailSettings"))
{
using var cmd = conn.CreateCommand();
cmd.CommandText = @"CREATE TABLE IF NOT EXISTS `SystemEmailSettings` (
`Id` int NOT NULL,
`Enabled` tinyint(1) NULL,
`SmtpHost` longtext NULL,
`SmtpPort` int NULL,
`SmtpUser` longtext NULL,
`SmtpPassword` longtext NULL,
`From` longtext NULL,
`FromName` longtext NULL,
`SmtpEnableSsl` tinyint(1) NULL,
`SmtpTimeoutMs` int NULL,
PRIMARY KEY (`Id`)
);";
cmd.ExecuteNonQuery();
}
if (!HasMySqlTable(conn, "CvUploadArtifacts"))
{
using var cmd = conn.CreateCommand();
@@ -0,0 +1,71 @@
namespace JobTrackerApi.Services;
/// <summary>
/// Records the current table-creation owner while the legacy startup reconciler is retired in
/// migration-backed increments. This is a governance boundary, not a second schema definition.
/// A table must appear in exactly one creation set.
/// </summary>
internal static class StartupSchemaOwnership
{
internal static readonly IReadOnlySet<string> MigrationOwnedTables = new HashSet<string>(StringComparer.Ordinal)
{
"AccountDeletionFiles",
"AccountDeletionRequests",
"AiUsageRecords",
"Attachments",
"Companies",
"Correspondences",
"EmailDrafts",
"EmailSendAttempts",
"JobApplications",
"JobEvents",
"Jobs",
"RuleSettings",
"SystemEmailSettings",
"UserNotifications",
"UserOperations",
};
internal static readonly IReadOnlySet<string> ReconcilerOwnedTables = new HashSet<string>(StringComparer.Ordinal)
{
"AiInteractions",
"AiWorkspaceNotes",
"ApplicationChecklistItems",
"AspNetRoleClaims",
"AspNetRoles",
"AspNetUserClaims",
"AspNetUserLogins",
"AspNetUserRoles",
"AspNetUsers",
"AspNetUserTokens",
"CareerCertifications",
"CareerEducations",
"CareerExperiences",
"CareerLanguages",
"CareerProfiles",
"CareerProfileVersions",
"CareerProjects",
"CareerSkills",
"CoverLetterVersions",
"CvExtractionRuns",
"CvUploadArtifacts",
"CvVariants",
"CvVariantVersions",
"GmailConnections",
"GmailReviewDecisions",
"ImapConnections",
"InterviewPrepItems",
"InterviewPrepNotes",
"MicrosoftGraphConnections",
"TailoredCvDrafts",
"TrustedDevices",
"TwoFactorRecoveryCodes",
"UserRuleSettings",
"UserSessions",
};
// Historical migrations contain guarded compatibility bootstraps for these tables so direct
// EF tooling can traverse the chain. Their current creation owner remains the reconciler.
internal static readonly IReadOnlySet<string> MigrationCompatibilityBootstrapTables =
new HashSet<string>(StringComparer.Ordinal) { "AiInteractions", "AspNetUsers" };
}