fix(ci): the Postgres engine forks its context without reaching into nest

Server lint: src/db may not import src/nest, so the Postgres engine opens the request context with RequestContext.create itself, as demo-reset and the backup restore already do. Server types: the base EntityManager has no execute(); RESTORE-002 reads through the connection.
This commit is contained in:
Maurice
2026-11-29 12:31:02 +01:00
parent 67049c1065
commit 80853fcf03
2 changed files with 5 additions and 5 deletions
@@ -1,5 +1,4 @@
import type { DbEngineSettings } from '../../../app-config/db-settings';
import { withRequestContext } from '../../../nest/database/request-context';
import { NO_SAFETY_NET } from '../../legacy-baseline';
import { finishSchemaBootstrap, type AnyOrm } from '../../orm';
import type { DatabaseEngine } from '../engine';
@@ -9,7 +8,7 @@ import { bootstrapPostgresSchema, defaultPostgresBootstrapDeps, type PostgresBoo
import { pgServerAddress } from './server-address';
import { putTempSchemaLast } from './session-search-path';
import { sslOptionFor } from './ssl';
import type { EntityManager } from '@mikro-orm/core';
import { RequestContext, type EntityManager } from '@mikro-orm/core';
import type { DatabaseConnection } from 'kysely';
@@ -77,8 +76,9 @@ export class PostgresEngine implements DatabaseEngine {
const deps = this.bootstrapDeps(this.settings.url);
// Migrated in a request context of its own, so the migrations' transaction
// never lands on a caller's EntityManager (a restore's request, #3264; see
// runSchemaBootstrap).
await withRequestContext(orm, () =>
// runSchemaBootstrap). RequestContext directly: the data layer does not
// reach up into nest/ for the helper.
await RequestContext.create(orm.em, () =>
bootstrapPostgresSchema(orm, options.snapshot ? deps : { ...deps, safetyNet: NO_SAFETY_NET }),
);
await finishSchemaBootstrap(orm);