• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / cli / 27197280116

09 Jun 2026 09:35AM UTC coverage: 64.303% (-0.003%) from 64.306%
27197280116

push

github

web-flow
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>

10403 of 16178 relevant lines covered (64.3%)

7.07 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.28
/internal/db/diff/diff.go


Source Not Available

The file "internal/db/diff/diff.go" isn't available on github. Either it's been removed, or the repo root directory needs to be updated.

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc