Declarative schema migration generation broken for JOIN views after CLI update
Describe the bug
After upgrading to the latest Supabase CLI (2.34.3), supabase db diff in declarative schema mode is endlessly re-generating migrations for views that contain JOINs, even if no actual changes have been made to the view SQL.
Before the CLI update, these views were stable. Now, after every db diff, the same DROP VIEW / CREATE VIEW statements are produced, leading to an infinite migration loop.
To Reproduce Steps to reproduce the behavior:
- Upgrade to the latest Supabase CLI
- Have a project using declarative schema (supabase/schemas/*.sql).
- Include a view with a join, for example:
create or replace view public.timeslips_view as
select
o.name,
tr.timeslips_requested,
tr.created_at,
tr.download_link,
tr.modified_at
from public.timeslips_requests tr
left join public.organisations o on tr.organisation_id = o.id
order by tr.created_at desc;
- Create migration with
supabase stop && supabase db diff -f migration_name - Re-run the diff
Expected behavior If no changes have been made to the database or declarative schema, supabase db diff should produce no output.
Actual behavior The CLI repeatedly outputs the same DROP VIEW / CREATE VIEW statements for affected views. This repeats indefinitely after each run, even immediately after applying the migration.
Notes / Observations • The issue appears specific to views containing JOINs — views without joins are unaffected. • Happens whether or not schema qualification (public.) is used in the FROM clause. • Removing WITH (security_invoker...) and ALTER ... OWNER from the declarative schema does not resolve it. • Likely linked to a change in the CLI’s SQL deparser in the most recent release.