Category: Supabase and databases

PostgreSQL: 42P01 relation does not exist after migration

Read this guide in Polish

The application reports 42P01, although the table was created in a developer environment. The database does not find a relation under given name or in active search path.

How to determine the source of the error

Check the production database identifier, used schematic and current search path session.

Compare completed migrations with files in the repository instead of creating a table manually without history.

What to do step by step

1. Run missing, tested migrations on the right environment with backup.

2 . If the table exists in another scheme, use the correct selection scheme.Name and make sure the role has permission.

How to check the score

The query to the target database works both locally and on production, and migrations have the same version.

What to do

Do not reset the production base in response to a lack of one relationship.