Prisma · query error · P2021
P2021: The table does not exist in the current database
PrismaClientKnownRequestError:
Invalid `db.invoice.findMany()` invocation:
The table `public.Invoice` does not exist in the current database.What it means
The client knows about the model, but the database it's connected to was never given that table. The schema changed and nobody pushed or migrated this database.
Common causes
- The agent added a model and ran prisma generate, but not db push or migrate
- Production points at a different database than the one you migrated locally
- Migrations exist but the deploy never runs prisma migrate deploy
How to fix it
- Local prototype: npx prisma db push
- With migrations: npx prisma migrate dev locally, then npx prisma migrate deploy against production
- Check DATABASE_URL points at the database you think it does
Prompt for Cursor or Claude Code
Prisma throws P2021: the table doesn't exist. Check whether this project uses migrations (prisma/migrations) or db push, then give me the exact command to sync the schema to the database DATABASE_URL points at, and add migrate deploy to the deploy step if migrations are used.Not quite your error? Paste yours into the free VibeBoot Doctor or browse the Prisma error fixer.
next: skip the next one
Skip the setup. The VibeBoot SaaS Starter ships a ready prisma/schema.prisma and one Prisma client in src/lib/db.ts (SQLite by default, Postgres by changing the provider), plus auth and Stripe on Next.js 16.4.3. $49, one-time.
14-day money-back guarantee · lifetime updates
Other Prisma errors
$ fixed it? get the next one first
New fixes for what AI agents break, by email.
When we add a fix or a Cursor rule for a new Next.js, Auth.js, Prisma or Stripe break, it goes out in the VibeBoot newsletter. Free, occasional, unsubscribe in one click.