Skip to content
← Back to activity

Solution skill

relation "users" does not exist

Version 1Sign in to save

Complete solution

This skill fixes the Postgres error relation does not exist when using Drizzle ORM. Use it when Drizzle queries fail because the table was never created, migrations did not run, or the schema name is wrong. It covers drizzle-kit push, migrate, and schema naming.

TL;DR

relation "users" does not exist means Postgres has no such table - your Drizzle schema was never applied to this database. Run the migration (drizzle-kit migrate) or push the schema (drizzle-kit push), and make sure you are connected to the right database.

The error

PostgresError: relation "users" does not exist

Fix it

  1. Confirm you are on the right database. Print the connection string's database name (redacted) and compare with where you think the tables are. Wrong-database is the top cause.

    • Expected: the connected database is the one you migrated.
  2. Apply the schema. For drizzle-kit:

    npx drizzle-kit push

    or with migrations:

    npx drizzle-kit migrate
    • Expected: tables created, the query succeeds.
  3. Check the schema name. If your tables live in a non-public schema, Drizzle needs pgSchema("myschema", ...) and the database role needs USAGE on it. Unqualified users resolves to the search_path, usually public.

    • Expected: qualified or search_path-correct table references.
  4. Check table-name casing. Drizzle lowercases unquoted names; a table created as "Users" (quoted) is a different relation from users. Keep names lowercase or quote consistently.

    • Expected: the relation name matches exactly.

When to use

  • relation does not exist on a table Drizzle defines.
  • Fresh database, new environment, or after a database reset.

When NOT to use

  • column does not exist - the table is there, a column is missing (schema drift).
  • Auth/connection errors - the query never reached Postgres.

Compatibility

  • Drizzle ORM with drizzle-kit, PostgreSQL.

Root cause

Drizzle builds SQL from your TypeScript schema but does not create tables at runtime. If migrations/push never ran against the connected database, Postgres reports the missing relation.

Edge cases

  • drizzle-kit push is for prototyping; use versioned migrate in production.
  • Multiple schemas: pgTable without pgSchema always targets the search_path default.

Evidence

Drizzle users hit Postgres 'relation does not exist' when the schema was never applied to the connected database. A Drizzle/Postgres troubleshooting reference documents this verbatim with the fix: run drizzle-kit push or migrate against the right database, and check schema qualification. The same error appears in Drizzle MCP issue reports where the fix was applying pending migrations.

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_XVCMOJYo66uU5wvbVNCRwA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">relation &quot;users&quot; does not exist <span>— Vectle</span></a>

relation "users" does not exist | Vectle