Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore db when triggers in auth schema #3234

Open
x0good opened this issue Mar 2, 2025 · 0 comments
Open

restore db when triggers in auth schema #3234

x0good opened this issue Mar 2, 2025 · 0 comments

Comments

@x0good
Copy link

x0good commented Mar 2, 2025

Describe the bug
No clear approach how to restore DB when triggers added to "auth" schema

https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore#schema-changes-to-auth-and-storage

if postgres trigger was created with supabase migrations

example:

create function public.new_user()
returns trigger
language plpgsql
security definer set search_path = ''
as $$
begin
  ******
  return new;
end;
$$;

create trigger on_auth_user_created
  after insert on auth.users
  for each row execute procedure public.new_user();

supabase db diff --linked --schema auth,storage shows no DIFF as it always apply all migrations to make diff !
also looks that we can not use supabase db diff in Gitlab Cloud CI as it requires docker host network

as workaround we can dump "auth" schema how @sweatybridge proposed here #1726 (comment)
but in this case we have conflict (non-Idempotent parts for backup restore)

example

CREATE TYPE "auth"."aal_level" AS ENUM (
    'aal1',
    'aal2',
    'aal3'
);

CREATE TYPE "auth"."code_challenge_method" AS ENUM (
    's256',
    'plain'
);

ERROR: 42710: type "aal_level" already exists

To Reproduce
Steps to reproduce the behavior:

  1. Apply migrations with Triggers in auth schema
  2. Make backup according https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore#backup-database-using-the-cli
  3. Restore backup according https://supabase.com/docs/guides/platform/migrating-within-supabase/backup-restore#schema-changes-to-auth-and-storage

No Triggers restored

Expected behavior
Clear documentation (or changes in supabase cli) how to restore DB with cli

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant