Add Postgres pool, health query and start-time migrations

This commit is contained in:
Grok Bot
2026-11-26 09:10:37 +00:00
parent 3c470ba85b
commit 4924059685
3 changed files with 134 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
// Next.js calls register() once when the server starts (also in the standalone server),
// which is where we run migrations. It runs before the first request is served.
export async function register() {
if (process.env.NEXT_RUNTIME !== 'nodejs') return;
if (process.env.NEXT_PHASE === 'phase-production-build') return; // never migrate during `next build`
if (process.env.SKIP_MIGRATIONS === '1') return;
const { runMigrations } = await import('./lib/migrate');
try {
await runMigrations();
} catch (e) {
console.error('[migrate] FATAL:', (e as Error).message);
process.exit(1); // let the platform restart / surface the failure
}
}