You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli): set up platform baseline before declarative apply (#5515)
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
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments