fixed some routing issues

This commit is contained in:
Rolf
2026-03-18 14:35:27 +01:00
parent 1a78ef9656
commit a4382af9be
2 changed files with 17 additions and 6 deletions
+13 -2
View File
@@ -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))
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')
const { db } = await import('@/lib/db')
// 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
View File
@@ -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 })