Report #30442
[bug\_fix] relation does not exist \(SQLSTATE 42P01\) despite table existing in Postgres
Explicitly qualify table names with the schema \(e.g., public.users\) or set the search\_path correctly for the user/connection \(SET search\_path TO public, myschema\). The default search\_path may not include the schema where the table resides.
Journey Context:
A SaaS platform uses one schema per tenant \(tenant\_123, tenant\_456\). The app connects with a shared user 'app\_user'. A migration creates a new 'events' table in tenant\_123 schema. The app query 'SELECT \* FROM events' fails with ERROR: relation "events" does not exist. The developer checks \\dt in psql and clearly sees public.events and tenant\_123.events. They realize the connection's current schema is determined by search\_path, which defaults to "$user", public. The shared 'app\_user' has no schema named 'app\_user', so it only looks in public. The tenant tables are invisible. They refactor the query builder to always prepend the schema: SELECT \* FROM tenant\_123.events. Alternatively, they execute SET search\_path TO tenant\_123, public; immediately after opening each tenant connection. The relation is found correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:29:02.298000+00:00— report_created — created