Skip to content

fix: Migration error with different auth schema #1983

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

willnode
Copy link

@willnode willnode commented Apr 9, 2025

What kind of change does this PR introduce?

Fixes #1729

What is the current behavior?

Doesn't nicely play if default schema is other than "auth"

What is the new behavior?

Migration will be fine

Additional context

Add any other context or screenshots.

image

@willnode willnode requested a review from a team as a code owner April 9, 2025 02:23
@willnode
Copy link
Author

willnode commented Apr 9, 2025

I have confirmed that executing this to the DB directly will make it healthy

alter type factor_type add value 'phone';
alter table auth.mfa_factors add column if not exists phone text unique default null;
alter table auth.mfa_challenges add column if not exists otp_code text null;
create unique index if not exists unique_verified_phone_factor on auth.mfa_factors (user_id, phone);

insert into public.schema_migrations (version) values ('20240729123726');

@willnode
Copy link
Author

willnode commented Apr 9, 2025

image

If you wonder what happens if we completely discard schema in enum types.

@hf
Copy link
Contributor

hf commented Apr 14, 2025

Hmm this seems off. Are you specifying your schema in the migrations correctly?

@willnode
Copy link
Author

Here's my compose file: https://github.com/willnode/supabase-docker/blob/main/docker-compose.yml.

I do not set "DB_NAMESPACE" and I do not set the default postgres search path to be "auth" since I want to use my external postgres database. The only thing that prevents me from using my external database is this PR.

I could reverse this change, so the enum would be namespaced correctly, but it would be adding namespace for enum types from migrations/20221003041349_add_mfa_schema.up.sql and every migration files of it after.

@willnode
Copy link
Author

OK I understand whythe "default" way to install in docker works, the search path is set in the script:

ALTER USER supabase_auth_admin SET search_path = '$DB_NAMESPACE';

We do not set separate postgres account in each docker service, so we don't have the opportunity to set this. We just set one postgres account to all services in the compose file. Setting the search path is not a reasonable option in this case.

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

Successfully merging this pull request may close these issues.

Issue with migrations
2 participants