Files
TREK/server/tests/integration/legacy-upgrade-v066.test.ts
T
Maurice ca7cdcebcc 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.
2026-11-18 15:22:38 +01:00

40 lines
1.6 KiB
TypeScript

/**
* B1 / N1 (Plan 4 final review and its re-review): an install the retired
* positional runner migrated to schema_version 66 (5be2e9b26) boots on this
* release. It predates the ~30 tables that only `createTables()` ever made
* (photo_providers, photo_provider_fields, …), so the baseline migration must
* RUN on it, as the legacy boot did, not be recorded as executed.
* The assertions live in tests/helpers/legacy-upgrade-suite.ts.
*/
import { db as legacyDb } from '../../src/db/database';
import { describeLegacyUpgrade } from '../helpers/legacy-upgrade-suite';
import { vi } from 'vitest';
vi.mock('../../src/db/database', async () => {
const { buildDbMock } = await import('../helpers/db-mock');
const { openLegacyFixture } = await import('../helpers/legacy-fixture');
return buildDbMock(openLegacyFixture('legacy-v066'));
});
describeLegacyUpgrade(
{
fixture: 'legacy-v066',
version: 66,
reseated: 1,
nightOrderIndex: 1,
id: 'LEGACYUP-066',
// Carried from the legacy chain itself, not caused by the upgrade: an install
// 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'],
},
},
legacyDb,
);