Declarative schema migration generation broken for JOIN views after CLI update
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- postgresql, typescript
Research direction
Start by reproducing the behavior with Supabase CLI 2.34.3 using a declarative schema in supabase/schemas/*.sql and a view containing a JOIN. Trace the supabase db diff path and its SQL deparser, comparing the generated DROP VIEW / CREATE VIEW statements across repeated runs. Done means an unchanged JOIN view produces no migration output after the migration is applied.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 523
- Avg merge
- 20h 47m
- Merged PRs (30d)
- 243
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from supabase/cli
-
🐛 Bug supabase/cli
-
🐛 Bug supabase/cli
-
🐛 Bug supabase/cli
-
Local Kong keeps idle upstream connections longer than PostgREST, causing sporadic 502 on POST/PATCH Open🐛 Bug supabase/cli
-
✨ Feature supabase/cli
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
fullcalendar/fullcalendar#8106 ·