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

Diff command fails because pg_jsonschema is not enabled on shadow db #2088

Closed Davidtozz closed 7 months ago

Davidtozz commented 7 months ago

Describe the bug Using the diff command with extensions not enabled by default results in error. In my case, i enabled (other than the default extensions) the pg_jsonschema extensions, to validate a column holding JSONB data. It seems that the shadow db, created during the execution of the diff command, doesn't take into account possible extensions enabled on the main supabase instance, and therefore apply them before comparing changes.

To Reproduce Steps to reproduce the behavior:

  1. From the Supabase Dashboard, search and enable pg_jsonschema
  2. Apply some changes to the database, including at least 1 JSONB field with a check having a function from pg_jsonschema (ex. jsonb_matches_schema() )
  3. Run supabase db diff
  4. See error

Expected behavior No errors are thrown, shadow db and the command outputs the expected result

Screenshots If applicable, add screenshots to help explain your problem.

System information Rerun the failing command with --create-ticket flag.

Additional context If applicable, add any other context about the problem here.

sweatybridge commented 7 months ago

Do you have create extension if not exists pg_jsonschema in any of your migration files?

Davidtozz commented 7 months ago

Nope, I solved the issue by including that line in my first migration file. Can't believe the issue was that simple, thanks a lot!