fixed some routing issues
This commit is contained in:
+16
-5
@@ -1,4 +1,5 @@
|
||||
export async function register() {
|
||||
console.log('[instrumentation] register() called, NEXT_RUNTIME =', process.env.NEXT_RUNTIME)
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
const fs = await import('fs')
|
||||
const path = await import('path')
|
||||
@@ -9,10 +10,20 @@ export async function register() {
|
||||
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')
|
||||
console.log('[migrations] Applying migrations...')
|
||||
try {
|
||||
const postgres = (await import('postgres')).default
|
||||
const { drizzle } = await import('drizzle-orm/postgres-js')
|
||||
const { migrate } = await import('drizzle-orm/postgres-js/migrator')
|
||||
|
||||
// Dedicated single connection for migrations — never share with the app pool
|
||||
const client = postgres(process.env.DATABASE_URL!, { max: 1, connect_timeout: 10 })
|
||||
const db = drizzle(client)
|
||||
await migrate(db, { migrationsFolder: './lib/db/migrations' })
|
||||
await client.end()
|
||||
console.log('[migrations] Done')
|
||||
} catch (err) {
|
||||
console.error('[migrations] Failed:', err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@ import { drizzle } from 'drizzle-orm/postgres-js'
|
||||
import postgres from 'postgres'
|
||||
import * as schema from './schema'
|
||||
|
||||
const client = postgres(process.env.DATABASE_URL!)
|
||||
const client = postgres(process.env.DATABASE_URL!, { connect_timeout: 10 })
|
||||
export const db = drizzle(client, { schema, logger: true })
|
||||
|
||||
Reference in New Issue
Block a user