19 lines
682 B
TypeScript
19 lines
682 B
TypeScript
export async function register() {
|
|
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
|
const fs = await import('fs')
|
|
const path = await import('path')
|
|
const journal = path.join(process.cwd(), 'lib/db/migrations/meta/_journal.json')
|
|
|
|
if (!fs.existsSync(journal)) {
|
|
console.warn('[migrations] No journal found at', journal, '— skipping')
|
|
return
|
|
}
|
|
|
|
console.log('[migrations] Applying migrations from', path.dirname(journal))
|
|
const { migrate } = await import('drizzle-orm/postgres-js/migrator')
|
|
const { db } = await import('@/lib/db')
|
|
await migrate(db, { migrationsFolder: './lib/db/migrations' })
|
|
console.log('[migrations] Done')
|
|
}
|
|
}
|