refactor(db): migrate auth support tables

Move recovery codes, trusted devices, and revocable sessions into an additive provider-aware migration. Preserve existing security records and retain guarded MariaDB repairs for historical schemas.
This commit is contained in:
cesnimda
2026-08-30 16:52:07 +02:00
parent b425f1edc5
commit 2e2d649f6f
9 changed files with 209 additions and 113 deletions
+10 -5
View File
@@ -1,9 +1,9 @@
# JT-019 schema ownership — first migration-backed transfer
# JT-019 schema ownership — incremental migration transfers
## Scope
This increment establishes a behaviour-preserving ownership boundary and moves one independent
table. It does not attempt to delete the legacy reconciler wholesale.
This work establishes a behaviour-preserving ownership boundary and moves small independent or
cohesive table groups. It does not attempt to delete the legacy reconciler wholesale.
## Implemented
@@ -19,6 +19,9 @@ table. It does not attempt to delete the legacy reconciler wholesale.
for the independent per-user rule-settings table.
- Added `20260830122000_AdoptGmailReviewDecisionsSchema`, removed the SQLite startup-create path,
and supplied the previously absent MariaDB table definition.
- Added `20260830123000_AdoptAuthenticationSupportSchema` for recovery codes, trusted devices, and
revocable user sessions; both provider startup-create paths are removed while guarded MariaDB
repair checks remain for historical schemas.
- Corrected the ownership runbook: new tables now default to migrations; the reconciler is legacy
compatibility code to retire one dependency group at a time.
@@ -38,14 +41,16 @@ migration.
settings row, upgrades without changing that row.
- A representative per-user rules row survives adoption, downgrade, and re-upgrade.
- A representative Gmail review decision survives adoption, downgrade, and re-upgrade.
- Representative recovery-code, trusted-device, and user-session rows survive adoption, downgrade,
and re-upgrade, and their indexes are present afterwards.
- Generated MariaDB SQL contains the provider-correct `SystemEmailSettings` DDL.
- Full backend: 724/724 passed after all three leaf-table transfers.
- Full backend: 725/725 passed after the authentication-support transfer.
- Fresh application startup over a new disposable SQLite database applied
`20260830120000_AdoptSystemEmailSettingsSchema` and reached the healthy listening state.
## Remaining JT-019 work
Thirty-two model tables remain startup-created, including the Identity group and several tables
Twenty-nine 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.