cli icon indicating copy to clipboard operation
cli copied to clipboard

`ERROR: column "public" of relation "buckets" does not exist (SQLSTATE 42703)` During `supabase db reset`

Open ghost opened this issue 3 years ago • 32 comments

Describe the bug I was previously using v1.68.6 of the cli, and had no problem running migrations that included, among other things:

-- supabase/migrations/20230420235920_buckets.sql
insert into storage.buckets (id, name, public)
  values
    ('public', 'public', 'TRUE'),
    ('private', 'private', 'FALSE');

I then upgraded to v1.75.3 and the following error began presenting itself:

Applying migration 20230420235920_buckets.sql...
ERROR: column "public" of relation "buckets" does not exist (SQLSTATE 42703)
At statement 0: insert into storage.buckets (id, name, public)              
  values                                                                    
    ('public', 'public', 'TRUE'),                                           
    ('private', 'private', 'FALSE')                                         
Try rerunning the command with --debug to troubleshoot the error.

I tried running the exact same query in an empty project, using v1.75.3, without any migrations, once supabase db reset finished (from the web UI's SQL Editor) and get no errors (Success. 0 rows returned).

To Reproduce Steps to reproduce the behavior:

  1. Create a new supabase project without any migrations
cd ~ && mkdir supabase-bug-test
cd supabase-bug-test
supabase init && supabase start
  1. Create a new migration:
supabase migration new buckets
  1. Add the following to the newly created migration:
-- supabase/migrations/..._buckets.sql
insert into storage.buckets (id, name, public)
  values
    ('public', 'public', 'TRUE'),
    ('private', 'private', 'FALSE');
  1. Attempt to reset the database (supabase db reset)

Expected behavior The database should not be throwing the error (indeed, it worked all the way to, at least, v1.68.6 and broke somewhere between v1.75.3)

Desktop (please complete the following information):

  • OS: Mac OS 13.3 (22E252)
  • Version of CLI:
    • v1.68.6 (no error)
    • v1.75.3 (error)

Edit: current workaround is downgrading back to 1.68.6:

brew tap-new supabase/local-tap                                      
brew extract --version=1.68.6 supabase/tap/supabase supabase/local-tap
brew install [email protected]
supabase -v

ghost avatar Jul 04 '23 01:07 ghost

Can you try supabase stop --no-backup before running supabase start? This flag cleans up any db volumes leftover from previous runs to ensure a clean start.

I can't seem to reproduce on a clean start.

sweatybridge avatar Jul 04 '23 03:07 sweatybridge

@sweatybridge I tried your suggestion, and running supabase stop --no-backup followed by supabase start manages to reset everything fine, however I am still getting the exact same issue when I try and run supabase db reset.

ghost avatar Jul 04 '23 03:07 ghost

Here's the output:

nrb@nrb-mbp inspire-tms-frontend % supabase stop --no-backup
Stopped supabase local development setup.
nrb@nrb-mbp inspire-tms-frontend % supabase start
Applying migration 20230420161043_diff.sql...
Applying migration 20230420174112_diff.sql...
Applying migration 20230420184424_diff.sql...
Applying migration 20230420225315_diff.sql...
Applying migration 20230420230056_diff.sql...
Applying migration 20230420231240_diff.sql...
Applying migration 20230420231424_diff.sql...
Applying migration 20230420231755_diff.sql...
Applying migration 20230420235920_buckets.sql...
Applying migration 20230421000801_diff.sql...
Applying migration 20230421010505_diff.sql...
...
Applying migration 20230704003913_diff.sql...
Applying migration 20230704004639_diff.sql...
Applying migration 20230704004651_create_public_profiles_picture_folder.sql...
Applying migration 20230704013509_allow_users_to_create_company_private_folder.sql...
Seeding data supabase/seed.sql...
Started supabase local development setup.

         API URL: http://localhost:54321
     GraphQL URL: http://localhost:54321/graphql/v1
          DB URL: postgresql://postgres:postgres@localhost:54322/postgres
      Studio URL: http://localhost:54323
    Inbucket URL: http://localhost:54324
      JWT secret: super-secret-jwt-token-with-at-least-32-characters-long
        anon key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
service_role key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
nrb@nrb-mbp inspire-tms-frontend % supabase db reset
Resetting local database...
Restarting containers...
Applying migration 20230420161043_diff.sql...
Applying migration 20230420174112_diff.sql...
Applying migration 20230420184424_diff.sql...
Applying migration 20230420225315_diff.sql...
Applying migration 20230420230056_diff.sql...
Applying migration 20230420231240_diff.sql...
Applying migration 20230420231424_diff.sql...
Applying migration 20230420231755_diff.sql...
Applying migration 20230420235920_buckets.sql...
ERROR: column "public" of relation "buckets" does not exist (SQLSTATE 42703)
At statement 0: insert into storage.buckets (id, name, public)              
  values                                                                    
    ('public', 'public', 'TRUE'),                                           
    ('private', 'private', 'FALSE')                                         
Try rerunning the command with --debug to troubleshoot the error.

ghost avatar Jul 04 '23 03:07 ghost

Thank you for clarifying. I managed to reproduce and will release a fix soon.

sweatybridge avatar Jul 04 '23 04:07 sweatybridge

Thanks for the quick turn-around @sweatybridge !

ghost avatar Jul 05 '23 14:07 ghost

@sweatybridge It seems tlike there's a regression and #1278 got reverted in v2.x for some reason as I currently have the exact same problem as described above with the latest version of the CLI

Apparently @AbdullahAhmadAAK had the same problem a few months ago with supabase/supabase#29804, but that one got closed by @Hallidayo due to inactivity

I would be happy to contribute a fix, but I'm not familiar with Go as a language unfortunately, so I'm hoping this one can get resolved by somebody from the supabase team 🙏

MichaelDeBoey avatar Aug 27 '25 13:08 MichaelDeBoey

@MichaelDeBoey I had the same issue. Upgrading the supabase cli from 2.31.8 to 2.45.5 resolved it

andrew-wang-polar avatar Sep 23 '25 18:09 andrew-wang-polar

I'm seeing the same issue today:

ERROR: column "public" of relation "buckets" does not exist (SQLSTATE 42703)
At statement: 0
-- Create the migration-blobs bucket
insert into storage.buckets
  (id, name, public, file_size_limit)
             ^
Try rerunning the command with --debug to troubleshoot the error.

❯ which supabase /opt/homebrew/bin/supabase ❯ supabase --version 2.45.5

grant avatar Sep 25 '25 19:09 grant

SAME

ERROR: column "public" of relation "buckets" does not exist (SQLSTATE 42703)
At statement: 0
-- Create a new bucket called 'avatars' with appropriate settings
insert into storage.buckets (id, name, public, file_size_limit, allowed_mime_types)

which supabase /opt/homebrew/bin/supabase

supabase --version 2.45.5

benschac avatar Sep 25 '25 20:09 benschac

Yep me too on 2.45.5

maxtuzz avatar Sep 25 '25 22:09 maxtuzz

We are also having problems on 2.45.5 as well.

ERROR: column "public" of relation "buckets" does not exist (SQLSTATE 42703)

RichardHruby avatar Sep 25 '25 23:09 RichardHruby

Hi- I think I'm experiencing something similar:

ERROR: function storage.enforce_bucket_name_length() does not exist (SQLSTATE 42883) At statement: 221 CREATE TRIGGER enforce_bucket_name_length_trigger BEFORE INSERT OR UPDATE OF name ON storage.buckets FOR EACH ROW EXECUTE FUNCTION storage.enforce_bucket_name_length()

also 2.45.5

jg33 avatar Sep 25 '25 23:09 jg33

Also experiencing this issue on version 2.45.5 of the CLI

r-bt avatar Sep 25 '25 23:09 r-bt

Has anyone got a workaround?

maxtuzz avatar Sep 26 '25 02:09 maxtuzz

hey yes, main branch of the cli repo has the fix

kaiba42 avatar Sep 26 '25 02:09 kaiba42

you can compile the binary yourself with go build -o supabase ., and just use it with any sub command e.g. ./supabase start

kaiba42 avatar Sep 26 '25 02:09 kaiba42

hopefully devs publish the latest soon

kaiba42 avatar Sep 26 '25 02:09 kaiba42

Thanks for digging @kaiba42, I did that and set up a supabase-custom alias. All working and I'm unblocked

maxtuzz avatar Sep 26 '25 02:09 maxtuzz

2.45.5

same with me

williamneves avatar Sep 26 '25 15:09 williamneves

I believe supabase@beta fixes this.

grant avatar Sep 26 '25 18:09 grant