Error with a FK on a schema that's not dumped
Problem
Migrating from Supabase Migrations.
When using Supabase Auth and trying to create a FK on Auth schema, if Auth schema isn't dumped, pgschema errors out with schema \"auth\" does not exist (SQLSTATE 3F000)". I don't want to dump Auth schema because it's managed by Supabase.
Reproduction
- Enable Supabase Auth
create table backend.users ( auth_user_id uuid not null unique references auth.users (id) on delete cascade);
Solution
What's the best solution for this case?
Use ignore https://www.pgschema.com/cli/ignore
Also see https://github.com/pgplex/pgschema/issues/234
Pro tip, if you point your AI agent to our docs: https://www.pgschema.com/, it usually would give you a quite good answer.
@tianzhou Thank you for answering. To be honest, neither I or AI managed to get it working with ignore, but adding an auth.users stub works.
@leonzaher I was curious why .ignore failed. That's something I need to look into it as I want people using supabase to have a good onboarding experience.
I just keep getting the same error: time=2026-08-17T12:14:52.306+02:00 level=DEBUG msg="SQL execution failed" description="apply desired state SQL to temporary schema" error="ERROR: schema \"auth\" does not exist (SQLSTATE 3F000)"
I tried ignoring both the constraint and auth table, with and without schema prefix.
Currently I have this added to main.sql: `create schema auth;
create table auth.users ( id uuid primary key, raw_app_meta_data jsonb );`
After this it works great and the tool is top tier.