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
+16 -5
View File
@@ -1,4 +1,5 @@
export async function register() { export async function register() {
console.log('[instrumentation] register() called, NEXT_RUNTIME =', process.env.NEXT_RUNTIME)
if (process.env.NEXT_RUNTIME === 'nodejs') { if (process.env.NEXT_RUNTIME === 'nodejs') {
const fs = await import('fs') const fs = await import('fs')
const path = await import('path') const path = await import('path')
@@ -9,10 +10,20 @@ export async function register() {
return return
} }
console.log('[migrations] Applying migrations from', path.dirname(journal)) console.log('[migrations] Applying migrations...')
const { migrate } = await import('drizzle-orm/postgres-js/migrator') try {
const { db } = await import('@/lib/db') const postgres = (await import('postgres')).default
await migrate(db, { migrationsFolder: './lib/db/migrations' }) const { drizzle } = await import('drizzle-orm/postgres-js')
console.log('[migrations] Done') 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
View File
@@ -2,5 +2,5 @@ import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres' import postgres from 'postgres'
import * as schema from './schema' 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 }) export const db = drizzle(client, { schema, logger: true })