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(db): log the demo baseline refusal through the logger, read the tool versions at once

Maurice410d2393e09f
diff --git a/server/src/db/engine/postgres/pg-process.ts b/server/src/db/engine/postgres/pg-process.ts
index 049840746..5740e3bf7 100644
--- a/server/src/db/engine/postgres/pg-process.ts
+++ b/server/src/db/engine/postgres/pg-process.ts
@@ -197,8 +197,9 @@ export async function refuseClientOlderThanServer(
binDir: string | undefined,
serverMajor: number,
): Promise<void> {
- for (const tool of tools) {
- const major = await pgToolMajor(tool, binDir);
+ const majors = await Promise.all(tools.map((tool) => pgToolMajor(tool, binDir)));
+ for (const [i, tool] of tools.entries()) {
+ const major = majors[i];
if (major !== null && major >= serverMajor) continue;
throw new Error(
`${tool} is version ${major ?? 'unknown'}, older than the PostgreSQL ${serverMajor} server, which it cannot ` +
diff --git a/server/src/demo/demo-reset.ts b/server/src/demo/demo-reset.ts
index b7d2a240b..41f9c442f 100644
--- a/server/src/demo/demo-reset.ts
+++ b/server/src/demo/demo-reset.ts
@@ -8,7 +8,7 @@ import {
} from '../db/repositories/DemoRepository';
import type { CarriedUserSessionRow } from '../db/repositories/UserSessions.repository';
import { dbNow } from '../db/types';
-import { logError } from '../nest/audit/audit-log.logger';
+import { logError, logWarn } from '../nest/audit/audit-log.logger';
import { DatabaseConnectionLostError, type DatabaseBackupStrategy } from '../nest/database/database-backup.interface';
import { applyDemoAddonPolicy } from './demo-addon-policy';
import { RequestContext, type EntityManager } from '@mikro-orm/core';
@@ -74,7 +74,7 @@ async function resetDemoUser(database: DatabaseBackupStrategy): Promise<void> {
// replaced by the current database once, with the reason in the log.
const refusal = await database.checkCopy(baselinePath);
if (refusal) {
- console.warn(
+ logWarn(
`[Demo Reset] The baseline cannot be restored here (${refusal}); saving the current database as the baseline.`,
);
await saveBaseline(database);