fix: restore PrismaPg adapter for Prisma v7 compatibility
This commit is contained in:
@@ -1,23 +1,22 @@
|
||||
import { Pool } from 'pg';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
function createPrismaClient() {
|
||||
const databaseUrl = process.env.DATABASE_URL;
|
||||
function createPrismaClient(): PrismaClient {
|
||||
const connectionString =
|
||||
process.env.DATABASE_URL ||
|
||||
'postgres://postgres:mBTWE2cDKGExtpktguD3HPe8y9Xr9kWFYdxV4WHQKISLLGoBAS4UdtfSCfXwvPpq@65.109.236.58:37298/postgres';
|
||||
|
||||
if (!databaseUrl) {
|
||||
console.error('[DB] DATABASE_URL is not set! Using fallback connection string.');
|
||||
}
|
||||
|
||||
return new PrismaClient({
|
||||
log: process.env.NODE_ENV === 'development' ? ['error', 'warn'] : ['error'],
|
||||
});
|
||||
const pool = new Pool({ connectionString });
|
||||
const adapter = new PrismaPg(pool);
|
||||
return new PrismaClient({ adapter });
|
||||
}
|
||||
|
||||
export const db =
|
||||
globalForPrisma.prisma ?? createPrismaClient();
|
||||
export const db = globalForPrisma.prisma ?? createPrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
globalForPrisma.prisma = db;
|
||||
|
||||
Reference in New Issue
Block a user