Skip to main content
Database & ORM · Developer Error Resolution Lab

Fix Prisma Error P2021: 'The table public.User does not exist in the current database'

Synchronize Prisma schema migrations with your target PostgreSQL/MySQL/SQLite database in local dev and CI/CD deployments.

Triggered Error Message:

PrismaClientKnownRequestError: The table `public.User` does not exist in the current database. (Code: P2021)

Customize Solution for Your Environment
# 1. Check migration status against current DATABASE_URL:
npx prisma migrate status

# 2. Apply pending migrations in production/CI:
npx prisma migrate deploy

# 3. Or push schema directly in rapid prototyping:
npx prisma db push

Root Cause & Mechanism Analysis

Why does this error occur?

Your application connected to a database where migrations have not yet been applied (`prisma migrate deploy` was skipped in the build/start pipeline), or `DATABASE_URL` points to an empty database schema.

Frequently Asked Questions

What is the difference between `prisma migrate dev` and `prisma migrate deploy`?
`migrate dev` creates new migration SQL files and may reset local databases; `migrate deploy` safely applies committed migrations in staging/production without prompting.
DEVSECOPS & CI/CD PARTNER2 Slots Open

Need Zero-Knowledge .env Secret Sync Across Your Engineering Team?

Explore Castov Env Vault for client-side AES-256-GCM encrypted environment sharing, or sponsor this engineering hub.

Browse All 54 Guides