feat(cli): set up platform baseline before declarative apply#5515
Merged
Conversation
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
Coverage Report for CI Build 27196998344Warning No base build found for commit Coverage: 64.285%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase@5515Preview package for commit |
Coly010
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
SetupShadowDatabasefunction indiff.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
setupShadowConnhelper, used by bothSetupShadowDatabaseandMigrateShadowDatabaseto avoid duplication.Updated declarative apply flow:
Generatenow callssetupShadowDatabasewhen reusing the baseline shadow for cache warmupgetDeclarativeCatalogRefcallssetupShadowDatabasebefore applying declarative schemasAdded tests:
TestSetupShadowDatabasevalidates that the function sets up the platform baseline without applying migrations, and theGeneratereuse 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/postgresimage pre-bakes part of theauthschema (overlap on replay), a fullpg_dumpallreplay 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