cli icon indicating copy to clipboard operation
cli copied to clipboard

Storage version mismatch causes `supabase db pull` to fail, breaks local DB

Open conte91 opened this issue 9 months ago • 6 comments

Describe the bug

After running supabase db pull on a fresh local instance of supabase (supabase start from a clean docker, then supabase link), the version mismatch between remote and local storage API breaks any attempt at pulling the remote DB into a local dev environment.

(This was also reported in https://github.com/supabase/cli/issues/2473#issuecomment-3845541267)

To Reproduce Steps to reproduce the behavior:

  • Start with a fresh computer, or docker volume prune everything related to supabase.
  • supabase link to a project running storage-api v1.33.0
  • Run with supabase services, note that storage-api wasn't updated
    • observe warnings saying remote storage-api doesn't match local
  • supabase db pull a copy of the remote db schema
  • supabase start the database, or supabase db diff against a declarative schema
  • Any command that needs to seed the DB fails with:
ERROR: function storage.delete_prefix_hierarchy_trigger() does not exist (SQLSTATE 42883) At statement: 486 CREATE TRIGGER objects_delete_delete_prefix AFTER DELETE ON storage.objects FOR EACH ROW EXECUTE FUNCTION storage.delete_prefix_hierarchy_trigger() Try rerunning the command with --debug to troubleshoot the error.

Expected behavior

  • supabase link updates the storage API (#2473 is still open, was not fixed by #3488, as reported by the many comments after closure).
  • supabase db pull finishes successfully and leaves the migrations file and local DB in a clean state
  • Running supabase db diff or supabase stop; supabase start works

Screenshots N/A

System information

  • Ticket ID: cbe7b37ee4784722a6a47fe7b5b9e98e
  • Version of OS: Ubuntu 24.04, ArchLinux, both running via npx supabase
  • Version of CLI: 2.75.5
  • Version of Docker: podman version 5.7.1
  • Versions of services: v1.37.0, v1.33.0 (see below)

Additional context It's very obvious that the problem is #2473, db link doesn't do anything:

(venv) (silverstream) [simo@hans silver_stream/devops] → supabase services
WARNING: You are running different service versions locally than your linked project:
supabase/storage-api:v1.37.0 => v1.33.0
Run supabase link to update them.

  
   SERVICE IMAGE          | LOCAL                  | LINKED     
  ------------------------|------------------------|------------
   supabase/postgres      | 15.6.1.134             | 15.6.1.134 
   supabase/gotrue        | v2.186.0               | v2.186.0   
   postgrest/postgrest    | v12.2.3                | v12.2.3    
   supabase/realtime      | v2.74.7                | -          
   supabase/storage-api   | v1.37.0                | v1.33.0    
   supabase/edge-runtime  | v1.70.1                | -          
   supabase/studio        | 2026.02.04-sha-fba1944 | -          
   supabase/postgres-meta | v0.95.2                | -          
   supabase/logflare      | 1.30.8                 | -          
   supabase/supavisor     | 2.7.4                  | -          

(venv) (silverstream) [simo@hans silver_stream/devops] → supabase link    
Selected project: ldmthucwtdlofuqowgkb
Finished supabase link.
(venv) (silverstream) [simo@hans silver_stream/devops] → supabase services
WARNING: You are running different service versions locally than your linked project:
supabase/storage-api:v1.37.0 => v1.33.0
Run supabase link to update them.

  
   SERVICE IMAGE          | LOCAL                  | LINKED     
  ------------------------|------------------------|------------
   supabase/postgres      | 15.6.1.134             | 15.6.1.134 
   supabase/gotrue        | v2.186.0               | v2.186.0   
   postgrest/postgrest    | v12.2.3                | v12.2.3    
   supabase/realtime      | v2.74.7                | -          
   supabase/storage-api   | v1.37.0                | v1.33.0    
   supabase/edge-runtime  | v1.70.1                | -          
   supabase/studio        | 2026.02.04-sha-fba1944 | -          
   supabase/postgres-meta | v0.95.2                | -          
   supabase/logflare      | 1.30.8                 | -          
   supabase/supavisor     | 2.7.4                  | -          

conte91 avatar Feb 06 '26 15:02 conte91

Same issue as mentioned here: https://github.com/supabase/cli/issues/2473#issuecomment-3845541267

WARNING: You are running different service versions locally than your linked project: supabase/storage-api:v1.35.3 => v1.33.0

documedicgp avatar Feb 06 '26 18:02 documedicgp

As a temp workaround I deleted from the schema migration (e.g. supabase/migrations/20260206190216_remote_schema.sql) the following lines at the very end of the file:

CREATE TRIGGER objects_delete_delete_prefix AFTER DELETE ON storage.objects FOR EACH ROW EXECUTE FUNCTION storage.delete_prefix_hierarchy_trigger();

CREATE TRIGGER objects_insert_create_prefix BEFORE INSERT ON storage.objects FOR EACH ROW EXECUTE FUNCTION storage.objects_insert_prefix_trigger();

CREATE TRIGGER objects_update_create_prefix BEFORE UPDATE ON storage.objects FOR EACH ROW WHEN (((new.name <> old.name) OR (new.bucket_id <> old.bucket_id))) EXECUTE FUNCTION storage.objects_update_prefix_trigger();

CREATE TRIGGER prefixes_create_hierarchy BEFORE INSERT ON storage.prefixes FOR EACH ROW WHEN ((pg_trigger_depth() < 1)) EXECUTE FUNCTION storage.prefixes_insert_trigger();

CREATE TRIGGER prefixes_delete_hierarchy AFTER DELETE ON storage.prefixes FOR EACH ROW EXECUTE FUNCTION storage.delete_prefix_hierarchy_trigger();

documedicgp avatar Feb 06 '26 19:02 documedicgp

Same issue here. I did the something like @documedicgp but instead of deleting the schemas, my team and I are commenting them before running supabase start.

leandrocabranes avatar Feb 09 '26 17:02 leandrocabranes

@saltcod you added the awaiting details label: did I miss something with the bug report / is there any extra info that you need from my side?

conte91 avatar Feb 16 '26 21:02 conte91

Friendly ping @saltcod, do you ned anything from our side? This and #4460 have been blocking a lot of users from updating their supabase for a long time now, I'm starting to worry this will have security implications on products due to outdated software?

conte91 avatar Apr 17 '26 15:04 conte91

Hi! Thanks for opening this issue.

We're closing this because it has not had any activity for 45 days, and we try to keep the Supabase CLI issue tracker focused on reports that are still current.

If this still reproduces on the latest Supabase CLI, please comment with /reopen on its own line and include your CLI version, updated reproduction steps, and any recent error output. We appreciate the signal and are happy to take another look.

github-actions[bot] avatar Jun 17 '26 18:06 github-actions[bot]