refactor(db): migrate CV extraction data
Move upload artifacts and extraction runs into an additive provider-aware migration. Preserve parsed results, indexes, and nullable artifact retention semantics.
This commit is contained in:
@@ -558,7 +558,7 @@ SEC-008 implements the same durable state machine with `<final>.uploading` and `
|
||||
|
||||
### P3-1 — Reduce dual schema ownership incrementally
|
||||
|
||||
**Status (2026-08-30): in progress.** All 49 model tables now have an executable, disjoint creation-owner classification. Nine formerly reconciler-created tables—including authentication support and all three email-provider connections—have moved through additive provider-aware migrations with legacy-row preservation, downgrade/retry safety, startup-DDL removal, fresh SQLite runtime proof and generated MariaDB SQL. The Gmail decision migration also closes its missing MariaDB creation path. Twenty-six startup-created tables remain; see `docs/verification/jt-019-schema-ownership.md` and V-194–V-198.
|
||||
**Status (2026-08-30): in progress.** All 49 model tables now have an executable, disjoint creation-owner classification. Eleven formerly reconciler-created tables—including authentication support, email-provider connections, and CV extraction persistence—have moved through additive provider-aware migrations with legacy-row preservation, downgrade/retry safety, startup-DDL removal, fresh SQLite runtime proof and generated MariaDB SQL. The Gmail decision migration also closes its missing MariaDB creation path. Twenty-four startup-created tables remain; see `docs/verification/jt-019-schema-ownership.md` and V-194–V-199.
|
||||
|
||||
- **Findings/scope:** JT-019; inventory reconciler operations and move stable schema ownership to EF migrations in small steps.
|
||||
- **Dependencies:** provider upgrade fixtures and P2-2 restore safety.
|
||||
|
||||
@@ -230,3 +230,4 @@ Output was reduced to filenames and commit counts. The token artifact appears un
|
||||
| V-196 | Ownership/migration chain; populated adoption/downgrade/retry; MariaDB script; full backend | Repository root / disposable local SQLite | Move GmailReviewDecisions to migration ownership and close the missing MariaDB table path | PASS — focused ownership/migration 8/8; representative decision survives adoption, downgrade and re-upgrade; generated MariaDB SQL contains provider-safe DDL; SQLite startup create is removed; full backend 724/724 | MariaDB SQL generated only; no provider account or production migration. Down preserves ambiguous legacy data by design. Thirty-two reconciler-owned tables remain | JT-019 third leaf transfer complete; provider runtime and dependency groups continue incrementally |
|
||||
| V-197 | Ownership/migration chain; populated adoption/downgrade/retry; index assertions; MariaDB script; full backend | Repository root / disposable local SQLite | Move the authentication-support group to migration ownership without invalidating recovery codes, trusted devices, or active sessions | PASS — focused ownership/migration 9/9; representative rows survive adoption, downgrade and re-upgrade; expected indexes exist; generated MariaDB SQL contains all three provider-safe definitions; both startup-create paths are removed; full backend 725/725 | MariaDB SQL generated only; no provider account or production migration. Guarded MariaDB index/auto-increment repairs remain temporarily. Twenty-nine reconciler-owned tables remain | JT-019 authentication-support transfer complete; dependent feature groups continue incrementally |
|
||||
| V-198 | Ownership/migration chain; populated adoption/downgrade/retry; encrypted-value and index assertions; MariaDB script; full backend | Repository root / disposable local SQLite | Move Gmail, Microsoft Graph, and IMAP connection records to migration ownership without losing credentials or sync state | PASS — focused ownership/migration 10/10; representative encrypted values survive adoption, downgrade and re-upgrade; all five expected indexes exist; generated MariaDB SQL contains all three provider-safe definitions; both startup-create paths are removed; full backend 726/726 | MariaDB SQL generated only; no provider account or production migration. Gmail column repair and guarded MariaDB index/auto-increment repairs remain temporarily. Twenty-six reconciler-owned tables remain | JT-019 email-provider transfer complete; dependent CV/career groups continue incrementally |
|
||||
| V-199 | Ownership/migration chain; populated adoption/downgrade/retry; FK/index assertions; MariaDB script; full backend | Repository root / disposable local SQLite | Move CV upload artifacts and extraction runs to migration ownership without losing import history | PASS — focused ownership/migration 11/11; artifact hash and structured result survive adoption, downgrade and re-upgrade; all three indexes exist; artifact deletion sets the run link null; generated MariaDB SQL contains provider-safe parent/child DDL; startup creates neither table; full backend 727/727 | MariaDB SQL generated only; no provider account or production migration. Guarded MariaDB index/auto-increment repairs remain temporarily. Twenty-four reconciler-owned tables remain | JT-019 CV extraction persistence transfer complete; tailored CV and career groups continue incrementally |
|
||||
|
||||
@@ -67,7 +67,7 @@ already-correct database. Two consequences worth knowing:
|
||||
Created by EF migrations, never by the reconciler:
|
||||
|
||||
`AccountDeletionFiles`, `AccountDeletionRequests`, `AiUsageRecords`, `Attachments`, `Companies`,
|
||||
`Correspondences`, `EmailDrafts`, `EmailSendAttempts`, `GmailConnections`,
|
||||
`Correspondences`, `CvExtractionRuns`, `CvUploadArtifacts`, `EmailDrafts`, `EmailSendAttempts`, `GmailConnections`,
|
||||
`GmailReviewDecisions`, `ImapConnections`, `JobApplications`, `JobEvents`, `Jobs`,
|
||||
`MicrosoftGraphConnections`, `RuleSettings`, `SystemEmailSettings`, `TrustedDevices`,
|
||||
`TwoFactorRecoveryCodes`, `UserNotifications`, `UserOperations`, `UserRuleSettings`, and `UserSessions`.
|
||||
@@ -92,6 +92,10 @@ The email-provider connection group (`GmailConnections`, `MicrosoftGraphConnecti
|
||||
additive Gmail sync-column repair plus guarded MariaDB identity/index repair; it does not create
|
||||
these tables.
|
||||
|
||||
The CV import persistence group (`CvUploadArtifacts` and `CvExtractionRuns`) moved in
|
||||
`20260830125000_AdoptCvExtractionSchema`. The extraction run's optional artifact foreign key remains
|
||||
`ON DELETE SET NULL`, so retention cleanup cannot erase the extraction/review record.
|
||||
|
||||
The reconciler may **repair** these (add a missing column, add an index, fix a non-`AUTO_INCREMENT`
|
||||
primary key) and may seed the default `RuleSettings` row — but it must never `CREATE TABLE` them.
|
||||
It used to create `RuleSettings`, which is precisely why a clean install failed with
|
||||
@@ -101,8 +105,7 @@ It used to create `RuleSettings`, which is precisely why a clean install failed
|
||||
|
||||
Created by `StartupInitializationExtensions`, with a **no-op migration** holding the model snapshot:
|
||||
|
||||
`CvUploadArtifacts`, `CvExtractionRuns`, `TailoredCvDrafts`,
|
||||
`CareerProfiles`, `CareerProfileVersions`, the six CareerProfile children (`CareerExperiences`,
|
||||
`TailoredCvDrafts`, `CareerProfiles`, `CareerProfileVersions`, the six CareerProfile children (`CareerExperiences`,
|
||||
`CareerEducations`, `CareerSkills`, `CareerProjects`, `CareerCertifications`, `CareerLanguages`),
|
||||
`InterviewPrepNotes`, `AiWorkspaceNotes`, `CvVariants`, `CvVariantVersions`, `AiInteractions`,
|
||||
`ApplicationChecklistItems`, `CoverLetterVersions`, and `InterviewPrepItems`.
|
||||
|
||||
@@ -25,6 +25,8 @@ cohesive table groups. It does not attempt to delete the legacy reconciler whole
|
||||
- Added `20260830124000_AdoptEmailConnectionSchema` for Gmail, Microsoft Graph, and IMAP connection
|
||||
records. Encrypted credentials and sync state are retained; scoped Gmail column repair and guarded
|
||||
MariaDB index/identity repair remain for historical installations.
|
||||
- Added `20260830125000_AdoptCvExtractionSchema` for upload artifacts and extraction runs, retaining
|
||||
parsed output and the nullable `ON DELETE SET NULL` artifact relationship.
|
||||
- Corrected the ownership runbook: new tables now default to migrations; the reconciler is legacy
|
||||
compatibility code to retire one dependency group at a time.
|
||||
|
||||
@@ -48,14 +50,16 @@ migration.
|
||||
and re-upgrade, and their indexes are present afterwards.
|
||||
- Representative encrypted credentials for all three email providers survive adoption, downgrade,
|
||||
and re-upgrade, and all five expected provider indexes are present afterwards.
|
||||
- Representative CV artifact metadata and structured extraction output survive adoption, downgrade,
|
||||
and re-upgrade; deleting the artifact preserves the run and clears its nullable relationship.
|
||||
- Generated MariaDB SQL contains the provider-correct `SystemEmailSettings` DDL.
|
||||
- Full backend: 726/726 passed after the email-provider connection transfer.
|
||||
- Full backend: 727/727 passed after the CV extraction persistence transfer.
|
||||
- Fresh application startup over a new disposable SQLite database applied
|
||||
`20260830120000_AdoptSystemEmailSettingsSchema` and reached the healthy listening state.
|
||||
|
||||
## Remaining JT-019 work
|
||||
|
||||
Twenty-six model tables remain startup-created, including the Identity group and several tables
|
||||
Twenty-four model tables remain startup-created, including the Identity group and several tables
|
||||
with parent dependencies. Transfer them in small dependency-aware migrations with blank, populated,
|
||||
retry and MariaDB runtime proof. Column/index repairs must remain until historical upgrade fixtures
|
||||
prove each one redundant.
|
||||
|
||||
@@ -48,6 +48,7 @@ Updated: 2026-08-30
|
||||
- Moved `GmailReviewDecisions` into a provider-aware migration, preserving existing SQLite decisions and closing the previously missing MariaDB table path.
|
||||
- Moved recovery codes, trusted devices, and revocable user sessions into one provider-aware authentication-support migration; populated legacy rows and indexes survive adoption, downgrade, and retry.
|
||||
- Moved Gmail, Microsoft Graph, and IMAP connection records into one provider-aware migration; encrypted credentials, sync state, uniqueness constraints, and historical repair paths are preserved.
|
||||
- Moved CV upload artifacts and extraction runs into a provider-aware migration; existing hashes, structured results, indexes, and nullable artifact retention semantics are preserved.
|
||||
|
||||
### In progress
|
||||
|
||||
@@ -78,7 +79,7 @@ Updated: 2026-08-30
|
||||
- Focused frontend: 2 suites, 6 tests passed.
|
||||
- Full frontend: 64 suites, 272 tests passed.
|
||||
- Next production build and TypeScript: passed.
|
||||
- Full backend: 726/726 tests passed after the email-provider JT-019 transfer.
|
||||
- Full backend: 727/727 tests passed after the CV extraction JT-019 transfer.
|
||||
- Portable Playwright launcher: resolved the user-local .NET 9 SDK; backend Release build passed with 0 warnings/errors.
|
||||
- Playwright: initial full run 9/10 exposed the intentional mobile Settings control change; updated focused rerun passed 1/1. A final complete browser rerun remains in the end-of-batch gate.
|
||||
- Focused backend match/intelligence verification: 34/34 passed.
|
||||
|
||||
Reference in New Issue
Block a user