cli icon indicating copy to clipboard operation
cli copied to clipboard

supabase db diff issue on v2.58.5

Open baresi687 opened this issue 3 months ago • 4 comments

Describe the bug supabase db diff shows schema changes no matter what.

To Reproduce

  1. Reset db locally
  2. Create new test function in public schema
  3. Generate new migration file with db diff
  4. Run supabase db diff

Expected behavior supabase db diff should return 'No schema changes found'. Instead it shows the test function.

System information

  • Version of OS: Ubuntu 24.04.3 LTS
  • Version of CLI: v2.58.5
  • Version of Docker: v28.3.3
  • Versions of services:
    supabase/postgres | 15.8.1.085
    supabase/gotrue | v2.182.1
    postgrest/postgrest | v13.0.7
    supabase/realtime | v2.63.0
    supabase/storage-api | v1.29.0
    supabase/edge-runtime | v1.69.23
    supabase/studio | 2025.11.10-sha-5291fe3
    supabase/postgres-meta | v0.93.1
    supabase/logflare | 1.25.3
    supabase/supavisor | 2.7.4

Additional context Tried rm -rf supabase/.temp/. No difference. Tested v2.59.6 pre release, same issue.

CLI versions 2.54.11 and 2.53.6 do not have this issue.

baresi687 avatar Nov 17 '25 14:11 baresi687

I've also noticed this behaviour. Functions always seem to appear in the diff

zahariaca avatar Nov 18 '25 18:11 zahariaca

I've been experiencing this on my end as well, regardless if I have new changes or not my schema file always contains certain functions/types despite them already being pushed to production

Xyeut avatar Dec 01 '25 08:12 Xyeut

I was using 2.47.2 without any diff issues. Now that version appears incompatible with the the current supabase docker images. Upgrading to latest 2.62.10 breaks this again. This is not the first bug reported on the diff breaking. I wish the team would prioritize this higher. I know diffing has never been 100% but it's been probably 99%. Not having a somewhat reliable diff makes the process my team has been organized around for months (update declarative schema files and generate appropriate migrations using diff anf then reviewing) completely useless.

freemarmoset avatar Dec 01 '25 21:12 freemarmoset

Can confirm this is happening for me to on 2.65.5. Functions that are part of previous migrations keep showing up in new migrations and it's a painful process to go through and delete them one by one without accidentally removing a change that is actually needed.

jeanmaried avatar Dec 16 '25 21:12 jeanmaried

Another issue is that renaming a column generates a DROP and an ADD statement. If you aren't super carefull you will accidentally drop a column and all it's values instead of just renaming it.

I just changed many functions in my projects and at this point it's pretty much impossible to review the diff. Please fix this 🙏🏻

jeanmaried avatar Dec 17 '25 22:12 jeanmaried

so this is still an issue on version 2.72.2. funny enough, we have 4 databases that we maintain, 3 of them sync perfectly fine but the 4th one keeps spitting out drop and create or replace views that are IDENTICAL to what the schema state is at, and i'm at my wits end..

ogmzh avatar Jan 18 '26 10:01 ogmzh

I'm experiencing the same issue while diffing our declarative schema against our migrations. Versions of Supabase CLI higher than v2.53.6 (the latest I've tested with is v2.72.7) will repeatedly (endlessly) result in migration file (with the exact same contents) for all views and materialized views that joins one or more times.

This prevents us from upgrading our CLI forwards from v2.53.6.

To Reproduce

  • Supabase v2.72.7 (or at least higher then v2.53.6, that version does still work)
  • Declarative Schema including one or more views with one or more joins
  • Matching migration file(s)
  • run $ supabase db diff -f changes (multiple times)

System information

  • MacOS v26.2 (25C56)
  • Docker v4.57.0 (215387)
  • supabase/postgres-meta:v0.95.2
  • supabase/edge-runtime:v1.70.0
  • supabase/storage-api:v1.33.5
  • supabase/postgrest:v14.3
  • supabase/realtime:v2.69.2
  • supabase/mailpit:v1.22.3
  • supabase/gotrue:v2.185.0
  • supabase/kong:2.8.1
  • supabase/vector:0.28.1-alpine
  • supabase/logflare:1.28.0
  • supabase/postgres:17.6.1.071

Result

This will repeatedly (endlessly) result in migration file (with the exact same contents) for all views and materialized views that joins one or more times.

Expected Behavior

  • No schema changes (especially after having ran $ supabase db diff -f changes once)

Failed workarounds

  • $ supabase db diff --use-pg-schema -f changes
    • WARNING: --use-pg-schema flag is experimental and may not include all entities, such as views and grants.
    • Keeps resulting in:
    • failed to generate plan: generating plan statements: generating migration statements: resolving table diff: generating alter statements for "public"."redacted": generating sql: altering base table: resolving check constraints sql: generating alter statements for validate_redacted: generating sql: check constraints that depend on UDFs: not implemented
  • $ supabase db diff --use-pg-delta -f changes
    • Keeps resulting in postgres role changes and one specific function
  • supabase db diff --use-pgadmin -f changes
    • Keeps resulting in:
    • ⢿ Diffing local database with current migrations... error running container: exit 1

Succesfull workaround

Downgrading Supabase CLI to v2.53.6

paulteriele avatar Jan 19 '26 13:01 paulteriele