refactor(db): migrate Identity schema
Complete schema ownership by moving all ASP.NET Identity tables to an additive provider-aware migration. Preserve credentials, security state, preferences, roles, claims, external logins, tokens, indexes, and cascades.
This commit is contained in:
@@ -65,7 +65,8 @@ already-correct database. Two consequences worth knowing:
|
||||
Created by EF migrations, never by the reconciler:
|
||||
|
||||
`AccountDeletionFiles`, `AccountDeletionRequests`, `AiInteractions`, `AiUsageRecords`, `AiWorkspaceNotes`,
|
||||
`ApplicationChecklistItems`, `Attachments`, `CareerCertifications`, `CareerEducations`,
|
||||
`ApplicationChecklistItems`, `AspNetRoleClaims`, `AspNetRoles`, `AspNetUserClaims`, `AspNetUserLogins`,
|
||||
`AspNetUserRoles`, `AspNetUsers`, `AspNetUserTokens`, `Attachments`, `CareerCertifications`, `CareerEducations`,
|
||||
`CareerExperiences`, `CareerLanguages`, `CareerProfiles`, `CareerProfileVersions`, `CareerProjects`,
|
||||
`CareerSkills`, `Companies`, `CoverLetterVersions`,
|
||||
`Correspondences`, `CvExtractionRuns`, `CvUploadArtifacts`, `CvVariants`, `CvVariantVersions`,
|
||||
@@ -132,6 +133,11 @@ child tables) moved in `20260830133000_AdoptCareerProfileSchema`. Canonical/long
|
||||
append-only history, stable child keys and ordering are retained; bounded MariaDB owner/item keys
|
||||
keep all aggregate indexes provider-safe.
|
||||
|
||||
The ASP.NET Identity aggregate moved in `20260830134000_AdoptIdentitySchema`. Accounts, password
|
||||
hashes, security/2FA state, UI preferences, roles, claims, external logins, tokens, indexes, and
|
||||
cascades are retained. The earlier guarded `AspNetUsers` bootstrap remains only so historical
|
||||
standalone migration traversal can reach later additive user-column migrations.
|
||||
|
||||
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
|
||||
@@ -139,12 +145,8 @@ It used to create `RuleSettings`, which is precisely why a clean install failed
|
||||
|
||||
### Reconciler-owned
|
||||
|
||||
The seven ASP.NET Identity tables are currently reconciler-owned, despite older wording that
|
||||
called them migration-owned: `AspNetRoles`, `AspNetUsers`, `AspNetRoleClaims`, `AspNetUserClaims`,
|
||||
`AspNetUserLogins`, `AspNetUserRoles`, and `AspNetUserTokens`. Guarded migration bootstraps for
|
||||
`AspNetUsers` supports standalone traversal but does not yet transfer ownership. The historical
|
||||
`AiInteractions` bootstrap remains in the migration chain, but its current owner is the later
|
||||
provider-aware adoption migration.
|
||||
None. The reconciler contains guarded historical repair logic, but it no longer creates EF model
|
||||
tables. Compatibility bootstraps inside old migrations are chain prerequisites, not current owners.
|
||||
|
||||
`StartupSchemaOwnership` is the executable inventory. Its tests require every EF model table to
|
||||
have exactly one creation owner and keep compatibility bootstraps out of the migration-owned set.
|
||||
@@ -222,9 +224,8 @@ everything inside it.
|
||||
|
||||
Standalone EF tooling is also supported for a blank SQLite database. The historical initial
|
||||
migration now supplies the stable JobApplication columns required by later SQLite rebuilds, and
|
||||
guarded compatibility bootstraps provide the reconciler-owned source tables used by later additive
|
||||
migrations. Application startup may subsequently reconcile the remaining Identity and auxiliary
|
||||
tables without losing rows.
|
||||
guarded compatibility bootstraps provide source tables used by later additive migrations.
|
||||
Application startup may subsequently apply guarded historical column/index repairs without losing rows.
|
||||
|
||||
## Production upgrade
|
||||
|
||||
|
||||
Reference in New Issue
Block a user