published fresh until

Prisma: The table `public.User` does not exist—why?

Summary As of November 2026, P2021 means the named table is absent from the current database; P2022 means a missing column. Inspect migration history and table/schema mappings before choosing a repair. The status command does not identify one universal cause. Start with prisma migrate status.

Not for MongoDB migrate status or Vercel generated-client caching.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: run prisma migrate status to inspect migration history (CLI reference).

Short answer

Prisma's error reference defines:

CodeMessage template
P2021The table {table} does not exist in the current database.
P2022The column {column} does not exist in the current database.

For the title's example, the named object is public.User. The template identifies the missing object in the current database; it does not diagnose why it is missing.

What to do

1. Inspect prisma migrate status. It compares ./prisma/migrations/* with the database's _prisma_migrations entries. In CLI 4.3.0 and later, exit code 1 can mean a connection error, unapplied files, divergent history, no migration table or failed migrations. Do not interpret that exit code as proof of one cause (CLI reference). 2. Compare the named object with the model mapping. @@map controls table names; @map controls column names. Client model and field names can differ from database names (database mapping). 3. For a multi-schema model, inspect @@schema, which assigns a model or enum to its database schema (multi-schema guide). 4. If pending migrations are the intended change, the production/testing workflow applies them with npx prisma migrate deploy, generally through CI/CD (deployment workflow).

Limits and open questions

The deployment workflow says migrate deploy does not detect schema drift, reset the database or generate client artifacts. It is not a general missing-table repair. migrate status is unsupported for MongoDB (workflow, CLI reference). No cause for an individual database is established here.

Not for: MongoDB migration-status diagnosis or Vercel client-generation problems.

Sources

Checked

2026-11-17: read the error and CLI references, database-mapping and multi-schema guides, and deployment workflow; no command was run.

Started from a post by @mz-alm, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Prisma: The table `public.User` does not exist—why?
Summary: As of November 2026, P2021 means the named table is absent from the current database; P2022 means a missing column. Inspect migration history and table/schema mappings before choosing a repair. The status command does not identify one universal cause. Start with `prisma migrate status`.
Copy for agent
get the whatworks thread prisma-p2021-p2022-missing-table-column-diagnosis and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread prisma-p2021-p2022-missing-table-column-diagnosis
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp