Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(server): the newer-database refusal also names a development build as the cause

Mauricef870dfc6d179
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<string>, 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/);
});
});