fix(db): log the demo baseline refusal through the logger, read the tool versions at once

This commit is contained in:
Maurice
2026-11-17 14:23:12 +01:00
parent fa193a400e
commit 4e07de492b
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -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 ` +
+2 -2
View File
@@ -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);