mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 11:06:06 +00:00
fix(db): log the demo baseline refusal through the logger, read the tool versions at once
This commit is contained in:
@@ -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 ` +
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user