Skip to content
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

"supabase db push" fails, generated migration contains schema "_analytics" #26245

Closed
2 tasks done
stefan-girlich opened this issue May 13, 2024 · 6 comments · Fixed by supabase/cli#2331
Closed
2 tasks done
Labels
bug Something isn't working cli Related to supabase/cli migrations Related to running and managing migrations with Supabase

Comments

@stefan-girlich
Copy link

stefan-girlich commented May 13, 2024

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I am not able to push a local migration to my linked cloud instance. The migration file contains internal tables from the _analytics schema.

To Reproduce

  1. Run supabase db diff -f change_purchase_id_type --use-migra (or without --use-migra)
  2. Run supabase db push
  3. See error, see created migration file

Expected behavior

  • Generated migration file only contains changes from public schema (?)
  • supabase db push succeeds

data

Commands and error

➜  backend git:(main) ✗ supabase db push
Connecting to remote database...
Do you want to push these migrations to the remote database?
 • 20240513093701_change_purchase_id_type.sql

 [Y/n] Y
Applying migration 20240513093701_change_purchase_id_type.sql...
ERROR: schema "_analytics" does not exist (SQLSTATE 3F000)
At statement 0: create sequence "_analytics"."billing_accounts_id_seq"
Try rerunning the command with --debug to troubleshoot the error.

Generated migration

migration.zip

  • Incorrectly (?) contains ~800 lines of code for _analytics schema
  • Correctly contains ~60 lines of code for public schema

System information

  • OS: MacOS
  • Version supabase CLI: 1.165.0
  • Version of Node.js: v21.6.2
@stefan-girlich stefan-girlich added the bug Something isn't working label May 13, 2024
@encima
Copy link
Contributor

encima commented May 14, 2024

Hey hey, thanks for opening!

By default, the migrations commands exclude system schemas but it can include them if it is run with -s. Was it ever run to include the _analytics schema or is this included consistently when you run commands like db dump or db pull?

I cannot reproduce but this does not mean it is not a bug! Just want to sanity check first that _analytics was never included. You can check this in your terminal history (ctrl+r) will allow you to search.

@encima encima added cli Related to supabase/cli migrations Related to running and managing migrations with Supabase labels May 14, 2024
@stefan-girlich
Copy link
Author

I only used -s public once with supabase db dump, but this did not affect migrations created afterwards. _analytics was never included explicitly. The migration just prior to the faulty one did not contain _analytics.

Happy to share a debug log if there is a way to exclude private/organization data.

@HoekWax
Copy link

HoekWax commented May 24, 2024

Hello, I have the same issue, I created a new project online, then linked it to a local projet, pulled the db. I then enabled "analytics" in config.toml then ran "db diff" to create a migration file which should not contain anything because it's a brand new project with nothing added but it does contain the definitions for the table _analytics.

@stefan-girlich
Copy link
Author

stefan-girlich commented May 27, 2024

Just upgraded my local environment to v1.167.4 (CLI); issue still exists.
When I create a new migration (e.g. supabase db diff -f add_output_tables --use-migra), the log output explicitly says that the extra schemas are included:

Diffing schemas: _analytics,_realtime,extensions,public

When I add -s public, the log will state Diffing schemas: public, but the actual migration file will still contain the extra schemas.

Update: It now worked as expected using -s public, still failing without.

@SuperstrongBE
Copy link

I have the exact same issue today.
Thank @stefan-girlich for the workaround.
But internal schema should be excluded while creating migration.

@sweatybridge
Copy link
Contributor

I've fixed this regression npx supabase@beta db diff. Apologies for the inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to supabase/cli migrations Related to running and managing migrations with Supabase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants