Skip to content

feat(cli): set up platform baseline before declarative apply#5515

Merged
avallete merged 4 commits into
developfrom
claude/busy-rubin-FY2Hn
Jun 9, 2026
Merged

feat(cli): set up platform baseline before declarative apply#5515
avallete merged 4 commits into
developfrom
claude/busy-rubin-FY2Hn

Conversation

@avallete

@avallete avallete commented Jun 8, 2026

Copy link
Copy Markdown
Member

Refs CLI-1601 — https://linear.app/supabase/issue/CLI-1601/support-auth-dependencies-in-shadow-db-migrations

Provision the Supabase platform schema (auth, storage, realtime, etc.) on shadow databases before applying declarative schemas, ensuring Supabase-managed dependencies resolve correctly during both declarative apply and cache warmup.

Changes

  • New SetupShadowDatabase function in diff.go: Provisions the platform baseline on a freshly created shadow database without applying user migrations. This allows declarative apply to share the same starting point as migration-based workflows.

  • Refactored shadow setup logic: Extracted common platform baseline setup into setupShadowConn helper, used by both SetupShadowDatabase and MigrateShadowDatabase to avoid duplication.

  • Updated declarative apply flow:

    • Generate now calls setupShadowDatabase when reusing the baseline shadow for cache warmup
    • getDeclarativeCatalogRef calls setupShadowDatabase before applying declarative schemas
    • This ensures platform objects (auth.sessions, auth.jwt(), etc.) are available during schema application and cancel out of diffs
  • Added tests: TestSetupShadowDatabase validates that the function sets up the platform baseline without applying migrations, and the Generate reuse test asserts the baseline is set up before declarative apply.

Note on baseline caching

A persistent "replayable SQL" baseline cache (so services don't boot on cold runs) was considered and intentionally not pursued — the supabase/postgres image pre-bakes part of the auth schema (overlap on replay), a full pg_dumpall replay is fragile (extensions/shared_preload_libraries/pgsodium/roles), and a pg-delta-derived baseline currently drops grants. See CLI-1601 for the full rationale.

https://claude.ai/code/session_01ACrX8NXcsYLENnCRXAub3S

The `db schema declarative sync` declarative shadow was a bare
supabase/postgres image with no gotrue/storage/realtime setup, so
declarative schemas that depend on Supabase-managed objects
(auth.sessions, auth.jwt(), ...) failed to apply with status "stuck".
The migrations shadow already runs SetupDatabase, so the two shadows
were asymmetric and platform objects could not resolve at apply time.

Extract SetupShadowDatabase (platform baseline, no user migrations) and
run it on the declarative shadow before applying declarative schemas, in
both the sync (getDeclarativeCatalogRef) and generate cache-warm paths.
Platform objects now appear identically in both shadows and cancel out
of the diff instead of surfacing as spurious changes or stuck applies.

Refs CLI-1601

https://claude.ai/code/session_01ACrX8NXcsYLENnCRXAub3S
@avallete avallete requested a review from a team as a code owner June 8, 2026 17:05
@coveralls

coveralls commented Jun 8, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27196998344

Warning

No base build found for commit 27b6af1 on develop.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 64.285%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 16178
Covered Lines: 10400
Line Coverage: 64.28%
Coverage Strength: 7.05 hits per line

💛 - Coveralls

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase@5515

Preview package for commit 643035d.

@avallete avallete merged commit 0e06255 into develop Jun 9, 2026
19 checks passed
@avallete avallete deleted the claude/busy-rubin-FY2Hn branch June 9, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants