pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Error with a FK on a schema that's not dumped

Open leonzaher opened this issue 3 months ago • 4 comments

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

  1. Enable Supabase Auth
  2. 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?

leonzaher avatar Aug 17 '26 09:08 leonzaher

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 avatar Aug 17 '26 10:08 tianzhou

@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 avatar Aug 17 '26 10:08 leonzaher

@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.

tianzhou avatar Aug 17 '26 10:08 tianzhou

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.

leonzaher avatar Aug 17 '26 11:08 leonzaher