T-2: M0.2 — Finish shared Postgres migrations: bun run db:migrate + fresh-database schema test

This commit is contained in:
Studio 2026-11-27 17:41:55 -05:00
parent 861ac72be0
commit c2db2d7495

View file

@ -1,4 +1,4 @@
import { mkdtempSync, rmSync } from 'node:fs';
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
@ -149,6 +149,8 @@ function runInitInIsolatedSubprocess(
mode: 'load-and-resolve' | 'load-only' = 'load-and-resolve'
): { exitCode: number; stdout: string; stderr: string } {
const isolatedDir = mkdtempSync(join(tmpdir(), 'stock-bot-db-migrate-env-'));
// Stop the config loader's upward .env search inside the temp directory.
writeFileSync(join(isolatedDir, '.env'), '', 'utf8');
const script =
mode === 'load-only'
? `import { loadMigrationConfig } from ${JSON.stringify(dbMigrateModuleUrl)};