Prisma error P2021 (Table Does Not Exist) explained: what it means, why it happens, and how to fix it — with copy-paste code examples.
Run npx prisma migrate dev (development) or prisma migrate deploy (production) to apply pending migrations. If that does not apply, for prototype stages without migration history, run npx prisma db push to sync the schema — the full checklist is below.
Error code: P2021
Official name: Table Does Not Exist
Service: Prisma
The table {table} does not exist in the current database.
npx prisma migrate dev
# or for production:
# npx prisma migrate deploy
migrate dev is for local development; migrate deploy applies existing migrations on production.
npx prisma db push
# pushes the schema directly; fine for early prototyping
db push creates the tables straight from the schema - no migration files are recorded.
npx prisma migrate dev applies pending migrations and regenerates the client in one step.
npx prisma migrate dev
# applies pending migrations, regenerates Prisma Client
Run migrations as part of the deploy pipeline (npm run prisma:migrate) before the app starts serving.
// package.json
"prisma:migrate": "prisma migrate deploy",
"start": "prisma migrate deploy && node dist/main.js"
Most often this happens when migrations were never applied (fresh clone, skipped prisma migrate dev), or when schema changes exist locally but were not pushed with prisma db push or migrate dev.
Run npx prisma migrate dev (development) or prisma migrate deploy (production) to apply pending migrations.
This page documents fixes for: prisma-cli, nestjs.
Recommendations are editorial — DB Error Reference takes no payment or affiliate fees for tool listings.
This page is based on the official Prisma documentation linked below and adds practical troubleshooting guidance on top.