Mendlark / Guides

Supabase "relation does not exist" (42P01): how to fix it

Your app or the Supabase SQL editor says ERROR: 42P01: relation "public.profiles" does not exist. Postgres is telling you the table (or view) it was asked for is not there, at least not under that exact name, in that schema, in that database. It usually worked in one place and not another, so the job is to find which of those three is different.

Stuck on this? Get it fixed for €49.

Fixed in 48 hours or you don't pay. Launch deal for the first 5 customers (normally €79). You get the tested fix as a pull request, so nothing changes until you merge it.

Get it fixed for €49

1. Check you are looking at the right project

Lovable, Bolt and Cursor apps often end up with two Supabase projects, one for testing and one live. Compare the project ref in your app's SUPABASE_URL (the part before .supabase.co) with the project open in your dashboard. If the live app points at a project where the table was never made, that is the bug.

2. Confirm the table really exists

Run this in the SQL editor of the project your app uses:

select table_schema, table_name
from information_schema.tables
where table_name ilike '%profiles%';

No rows means the table was never created there. Rows in a schema other than public means step 4 applies. A name like Profiles means step 5 applies.

3. Run the migration that creates it

AI builders often create tables through migration files in supabase/migrations. If those ran against your test project only, the live one is missing them. Link the CLI to the live project and push:

supabase link --project-ref your-live-ref
supabase db push

Or paste the create table SQL from the migration file into the live project's SQL editor. Take a backup first if the project already has real data. Then add the RLS policies and grants from the same migration, or the next error will be permission denied (42501).

4. The table is in another schema

Postgres looks in public unless told otherwise. If the table lives in, say, app or private, write the schema in SQL (select * from app.orders). From the JavaScript client, use supabase.schema('app').from('orders'), and add that schema under Settings → Data API → Exposed schemas, or the API will not see it.

5. Capital letters or spaces in the name

If the table was created as "Profiles" with quotes, Postgres stores the capital P and select * from profiles fails. Either quote it every time ("Profiles") or rename it once: alter table "Profiles" rename to profiles; and update your code to match.

6. A trigger or function cannot see the table

If the error appears when someone signs up (often shown as "Database error saving new user"), a trigger function is running with an empty search path and cannot find profiles. Write the full name inside the function, insert into public.profiles ..., and set its path:

create or replace function public.handle_new_user()
returns trigger language plpgsql security definer
set search_path = ''
as $$
begin
  insert into public.profiles (id) values (new.id);
  return new;
end;
$$;

7. The API still says it cannot find the table

If SQL works but the app gets "Could not find the table in the schema cache", the API has not reloaded. Run notify pgrst, 'reload schema'; and try again.

Quick checklist

  • App's SUPABASE_URL matches the project you are checking
  • Table shows up in information_schema.tables there
  • Migrations pushed to the live project, with policies and grants
  • Schema written out (or exposed) if it is not public
  • Name is lower case, or always quoted
  • Functions and triggers use public.table_name

Stuck on this? Get it fixed for €49.

Fixed in 48 hours or you don't pay. Launch deal for the first 5 customers (normally €79). You get the tested fix as a pull request, so nothing changes until you merge it.

Get it fixed for €49

Still stuck?

Mendlark fixes this kind of problem for a fixed €49 (launch price, normally €79). We agree the problem first, test the fix and send it as a pull request, so nothing changes in your app until you merge it. If we can't fix it, you don't pay. Get the €49 fix, or start with a free scan.

Not sure what else is wrong? Paste your app link into the free instant check and get a plain-English list of problems in seconds.