supabase / cli

Supabase CLI. Manage postgres migrations, run Supabase locally, deploy edge functions. Postgres backups. Generating types from your database schema.
https://supabase.com/docs/reference/cli/about
MIT License
1.07k stars 209 forks source link

supabase db pull doesn't pull storage policies #1840

Closed zhadavi closed 10 months ago

zhadavi commented 10 months ago

Describe the bug Running supabase db pull --schema storage doesn't generate any SQL for the storage policies.

To Reproduce Steps to reproduce the behavior:

  1. Create some storage schema policies on dashboard
  2. Run supabase db pull --schema storage locally
  3. Inspect generated migration SQL and see that no SQL is generated for storage policies
  4. Run studio via supabase start and see that no policies are under storage either

Expected behavior Expected that storage policies would be generated in the migration

Desktop (please complete the following information):

sweatybridge commented 10 months ago

Hi @zhadavi, I can't reproduce this problem using cli version 1.131.4.

Could you share the output of supabase services for a quick version check?

zhadavi commented 10 months ago

@sweatybridge sure

❯ supabase services

        SERVICE IMAGE      │        LOCAL         │   LINKED
  ─────────────────────────┼──────────────────────┼─────────────
    supabase/postgres      │ 15.1.0.153           │ 15.1.0.153
    supabase/gotrue        │ v2.132.3             │ v2.132.3
    postgrest/postgrest    │ v12.0.1              │ v12.0.1
    supabase/realtime      │ v2.25.50             │ -
    supabase/storage-api   │ v0.43.11             │ v0.43.11
    supabase/edge-runtime  │ v1.29.1              │ -
    supabase/studio        │ 20240101-8e4a094     │ -
    supabase/postgres-meta │ v0.75.0              │ -
    supabase/logflare      │ 1.4.0                │ -
    bitnami/pgbouncer      │ 1.20.1-debian-11-r39 │ -
    darthsim/imgproxy      │ v3.8.0               │ -

Also I just tried it again on cli version 1.131.4 and supabase db pull --schema storage still doesn't pull my policies on storage schema

sweatybridge commented 10 months ago

The versions look ok.

Could you double check that you have linked the right project by running supabase projects list?

If that's also ok, it might be specific to your hosted project. Please run supabase db pull --schema storage --create-ticket and reply the ticket id so we can look into it further.

zhadavi commented 10 months ago

Could you double check that you have linked the right project by running supabase projects list?

I think so, because supabase db pull still pulls everything from my other tables in that project.

❯ supabase projects list

    LINKED │        ORG ID        │     REFERENCE ID     │    NAME    │          REGION          │  CREATED AT (UTC)
  ─────────┼──────────────────────┼──────────────────────┼────────────┼──────────────────────────┼──────────────────────
      ●    │ fqlnolvgbnfjljddjboh │ ojigraocipagkwzmppak │ Ply Health │ East US (North Virginia) │ 2023-12-12 23:25:53

If that's also ok, it might be specific to your hosted project. Please run supabase db pull --schema storage --create-ticket and reply the ticket id so we can look into it further.

I ran the command but it doesn't look like it output a ticket ID:

❯ supabase db pull --schema storage --create-ticket
Connecting to remote database...
Schema written to supabase/migrations/20240117044800_remote_schema.sql
Update remote migration history table? [Y/n] n
Finished supabase db pull.
sweatybridge commented 10 months ago

Oh I see. This is indeed a misleading behaviour of CLI. If your local supabase/migrations directory is empty, db pull will ignore the --schema flag. I will make a PR to address this but meanwhile, you can work around it by pulling twice.

supabase db pull
supabase db pull --schema storage
la289 commented 8 months ago

This seems to still be an issue. Running the command twice, the first time without the schema flag, doesnt help @sweatybridge

jonathanlal commented 3 months ago

yeah also experiencing this issue still