21 lines
634 B
TypeScript
21 lines
634 B
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
import { PrismaPg } from '@prisma/adapter-pg'
|
|
import pg from 'pg'
|
|
|
|
const connectionString = process.env.DATABASE_URL!
|
|
|
|
function makePrisma() {
|
|
const pool = new pg.Pool({ connectionString })
|
|
const adapter = new PrismaPg(pool)
|
|
return new PrismaClient({ adapter })
|
|
}
|
|
|
|
const globalForPrisma = globalThis as unknown as { prisma_v2: PrismaClient }
|
|
|
|
// Updated: 2026-05-10T17:21 (Forced reload for OneShotPlan model)
|
|
export const prisma = globalForPrisma.prisma_v2 || makePrisma()
|
|
|
|
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma_v2 = prisma
|
|
|
|
export default prisma
|