Add Postgres pool, health query and start-time migrations
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user