0

While trying to create a local dev environment,

supabase db reset

is failing with

Resetting local database...
Recreating database...
Initialising schema...
Seeding globals from roles.sql...
Applying migration 20250316135437_remote_schema.sql...
Applying migration 20250316135745_remote_schema.sql...
ERROR: cannot drop function storage.get_level(text) because other objects depend on it (SQLSTATE 2BP01)
At statement 31:                                                                                       
drop function if exists "storage"."get_level"(name text)

How can I get past this?

1 Answer 1

3

The problem was due to having earlier issued

supabase db pull

then seeing the warning:

The auth and storage schemas are excluded. Run supabase db pull --schema auth,storage again to diff them.

and issuing the suggested,

db pull --schema auth,storage

Don't do that. Instead, start over with

rm -rf supabase/migrations/*

then in a single command, include all of the schemas:

supabase db pull --schema public,auth,storage

and the migration file will no longer try to drop a function with dependencies.

Sign up to request clarification or add additional context in comments.

1 Comment

As of the latest CLI, doing this does not resolve the problem it just hides it. supabase db pull --schema public,auth,storage does not seem to pull auth and storage. It still gives off the warning. So in order migrate storage, you need to run the pull twice to generate 2 migration files. So it leads to the same problem. A hack to solve this is to go into the storage migration file, and comment out the line that's causing that error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.