From f870dfc6d179b47d46b3774a3f0908a1d469901b Mon Sep 17 00:00:00 2001 From: Maurice Date: Tue, 13 Oct 2026 21:10:41 +0200 Subject: [PATCH] fix(server): the newer-database refusal also names a development build as the cause A database a feature-branch build migrated carries migrations this build does not ship too, and was told it came from a newer TREK. --- server/src/db/legacy-baseline.ts | 6 ++++-- server/tests/unit/db/known-migrations.test.ts | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/server/src/db/legacy-baseline.ts b/server/src/db/legacy-baseline.ts index e5265d7f4..e20ed1f74 100644 --- a/server/src/db/legacy-baseline.ts +++ b/server/src/db/legacy-baseline.ts @@ -251,7 +251,8 @@ export async function migrateToHead( /** * A database a newer TREK migrated carries migrations this build does not - * ship. An image rolled back, or a newer backup restored, would otherwise run + * ship; so does one a feature-branch build migrated, which is why the message + * names both. An image rolled back, or a newer backup restored, would otherwise run * older code against a schema it does not know and fail later, far from the * cause. Refused before anything is written. */ @@ -259,7 +260,8 @@ export function refuseNewerDatabase(executed: string[], known: Set, rest const unknown = unknownMigrations(executed, known); if (unknown.length === 0) return; throw new Error( - `${REFUSAL} the database was migrated by a newer TREK (${unknown.length} unknown migration(s), latest ${unknown[unknown.length - 1]}). ` + + `${REFUSAL} the database was migrated by a newer TREK (${unknown.length} unknown migration(s), latest ${unknown[unknown.length - 1]}), ` + + 'or by a development build that added migrations of its own. ' + 'Run that version again, or restore a backup taken with this one.' + (restoreHint ? ` ${restoreHint}` : ''), ); diff --git a/server/tests/unit/db/known-migrations.test.ts b/server/tests/unit/db/known-migrations.test.ts index 4aefd3305..4beb1927b 100644 --- a/server/tests/unit/db/known-migrations.test.ts +++ b/server/tests/unit/db/known-migrations.test.ts @@ -36,5 +36,6 @@ describe('known migrations', () => { expect(unknownMigrations(['Migration1_a', 'Migration3_c'], known)).toEqual(['Migration3_c']); expect(() => refuseNewerDatabase(['Migration1_a', 'Migration2_b'], known)).not.toThrow(); expect(() => refuseNewerDatabase(['Migration1_a', 'Migration3_c'], known)).toThrow(/newer TREK/); + expect(() => refuseNewerDatabase(['Migration1_a', 'Migration3_c'], known)).toThrow(/or by a development build/); }); });