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.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(db): sort the Postgres move's names with an explicit code-unit compare
Maurice7ae4dcba5117
diff --git a/server/src/db/engine/postgres/schema-bootstrap.ts b/server/src/db/engine/postgres/schema-bootstrap.tsindex e243b97a8..a0171c91e 100644--- a/server/src/db/engine/postgres/schema-bootstrap.ts+++ b/server/src/db/engine/postgres/schema-bootstrap.ts@@ -135,7 +135,7 @@ async function createFromBaseline(* that migration, when there is one.*/async function refuseNewerHistory(executed: string[], deps: PostgresBootstrapDeps): Promise<void> {- const thisRelease = migrationLabel([...deps.known].sort().at(-1) ?? '');+ const thisRelease = migrationLabel([...deps.known].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)).at(-1) ?? '');refuseNewerDatabase(executed, deps.known, await deps.safetyNet.restoreHint(thisRelease));}@@ -216,7 +216,7 @@ export async function bootstrapPostgresSchema(orm: AnyOrm, deps: PostgresBootstrif (pending.length === 0) return;// Only a database with history has a last migration to label its copy by; a// database the baseline just created has nothing yet to lose.- const latest = [...executed].sort().at(-1);+ const latest = [...executed].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)).at(-1);if (latest !== undefined) await deps.safetyNet.beforeMigrate(migrationLabel(latest));logger.log(`Applying ${pending.length} pending migration(s)`);await migrator.up();diff --git a/server/src/db/engine/postgres/sqlite-move/move.ts b/server/src/db/engine/postgres/sqlite-move/move.tsindex f642c46e9..ef94301df 100644--- a/server/src/db/engine/postgres/sqlite-move/move.ts+++ b/server/src/db/engine/postgres/sqlite-move/move.ts@@ -166,7 +166,7 @@ export function migrationLevelProblem(recorded: readonly string[] | null, known:if (unknown.length > 0) {return (`a newer TREK migrated the SQLite file (${unknown.length} migration(s) this version does not know, ` +- `the last ${[...unknown].sort().at(-1)}). Run the move with the TREK version that last ran on it.`+ `the last ${[...unknown].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)).at(-1)}). Run the move with the TREK version that last ran on it.`);}const have = new Set(recorded);diff --git a/server/src/db/engine/postgres/sqlite-move/order.ts b/server/src/db/engine/postgres/sqlite-move/order.tsindex e12d7b561..81d8bc9ac 100644--- a/server/src/db/engine/postgres/sqlite-move/order.ts+++ b/server/src/db/engine/postgres/sqlite-move/order.ts@@ -36,7 +36,7 @@ function defer(plan: CopyPlan, fk: ForeignKey): void {export function planCopyOrder(tables: readonly string[], foreignKeys: readonly ForeignKey[]): CopyPlan {const plan: CopyPlan = { order: [], deferred: new Map() };const known = new Set(tables);- const pending = new Set([...tables].sort());+ const pending = new Set([...tables].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)));const keys = foreignKeys.filter((fk) => known.has(fk.table) && known.has(fk.references));for (const fk of keys) if (fk.table === fk.references) defer(plan, fk);const between = keys.filter((fk) => fk.table !== fk.references);diff --git a/server/src/db/engine/postgres/sqlite-move/values.ts b/server/src/db/engine/postgres/sqlite-move/values.tsindex 8af67e8ef..61498ba21 100644--- a/server/src/db/engine/postgres/sqlite-move/values.ts+++ b/server/src/db/engine/postgres/sqlite-move/values.ts@@ -332,7 +332,7 @@ export function stableJson(text: string): string {if (value !== null && typeof value === 'object') {return Object.fromEntries(Object.keys(value)- .sort()+ .sort((a, b) => (a < b ? -1 : a > b ? 1 : 0)).map((key) => [key, sort((value as Record<string, unknown>)[key])]),);}