fix(db): add every column an upgraded pre-ORM install can lack

The legacy baseline records the positional runner's steps up to
schema_version as executed without running them, so a column that runner
never added stays missing for good. Two things in its history left such
gaps: a step inserted below a version a build had already shipped (step 53,
users.mfa_backup_codes, so turning on MFA failed there) and a column added
to createTables() with no step (users.immich_access_token).

Migration20200101046460 adds, where missing, every column the schema held
at legacy step 258 that head still holds and ALTER TABLE ADD COLUMN can
add, declared as head declares it; on Postgres every one of them is in the
baseline, so nothing is added there. The list is derived again from the
migrations in tests/unit/db/legacy-column-repair.test.ts, which also adds
all of them to a database lacking them and upgrades a v244 install shaped
like the one whose move to Postgres was refused.
This commit is contained in:
Maurice
2026-11-18 15:22:36 +01:00
parent 6bc27a259b
commit ca7cdcebcc
4 changed files with 1121 additions and 8 deletions
@@ -25,16 +25,14 @@ describeLegacyUpgrade(
nightOrderIndex: 1,
id: 'LEGACYUP-066',
// Carried from the legacy chain itself, not caused by the upgrade: an install
// this old got `users` and `reservations` from its own createTables(), and no
// numbered step ever adds `users.immich_access_token` or retypes
// `reservations.accommodation_id` (INTEGER there, TEXT in the baseline). The
// legacy runner at 417d0445b would have left the same two differences.
// this old got `reservations` from its own createTables(), and no numbered
// step ever retypes `reservations.accommodation_id` (INTEGER there, TEXT in
// the baseline). It also lacked `users.immich_access_token`, which no step
// adds either; Migration20200101046460 adds that one, as every column an
// ALTER TABLE can add.
carriedSchemaDiffs: {
onlyUpgraded: ['reservations.accommodation_id INTEGER notnull=0 default= pk=0'],
onlyFresh: [
'reservations.accommodation_id TEXT notnull=0 default= pk=0',
'users.immich_access_token TEXT notnull=0 default= pk=0',
],
onlyFresh: ['reservations.accommodation_id TEXT notnull=0 default= pk=0'],
},
},
legacyDb,