16 lines
662 B
TypeScript
16 lines
662 B
TypeScript
// 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
|
|
}
|
|
}
|