Skip to content

feat(cli): make pg-delta the only and the default diff engine - #6391

Open
avallete wants to merge 11 commits into
developfrom
claude/pg-delta-default-engine-rfpryl
Open

feat(cli): make pg-delta the only and the default diff engine#6391
avallete wants to merge 11 commits into
developfrom
claude/pg-delta-default-engine-rfpryl

Conversation

@avallete

@avalleteavallete commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

Two changes that finish the pg-delta migration, tracked as CLI-2211 and CLI-1588:

1. The in-process pg-delta engine is now the only pg-delta implementation (CLI-2211)

The SUPABASE_USE_PG_DELTA_NEXT escape hatch shipped in v2.115.0 as a temporary opt-out back to the legacy edge-runtime engine; its release notes announced removal after ~a month. Setting it now has no effect. Deleted with the legacy engine (net −4,300 lines):

  • the flag module and the engine selector layer; LegacyPgDeltaEngine loses its implementation discriminator and every handler branch keyed on it
  • the edge-runtime pg-delta Deno script templates, the supabase/.temp/pgdelta-version npm pin, and the PGDELTA_NPM_REGISTRY / PGDELTA_{SOURCE,TARGET}_SSLROOTCERT plumbing (all legacy-engine-only; the edge-runtime service itself stays — migra still runs through it)
  • the migrations-catalog cache warmups after db push / db reset / start / db start / bootstrap, and the whole catalog snapshot machinery (legacy-pgdelta.cache.ts); the shared migration lister moves to legacy-migration-list.ts
  • the legacy declarative catalog seam (LegacyDeclarativeSeam.exportCatalog), the declarative-apply engine (legacy-pgdelta.apply.ts), and db pull's legacy empty-diff debug bundle
  • the "--strict-coverage has no effect with the legacy pg-delta engine" warning — the flag is now always effective

2. pg-delta is the default diff engine for all projects (CLI-1588)

An absent [experimental.pgdelta] section — or a section that omits enabled — now resolves to pg-delta for db diff, db pull, and db remote commit, in the TypeScript CLI, @supabase/config (and the published JSON schema), and the Go binary backing the delegated db remote changes|commit / db pull --experimental commands.

The Go zero-value tri-state called out in CLI-1588 needed no *bool: the ejected config template now defaults enabled = true, and since mergeDefaultValues feeds that template to viper as the default config, viper's key-level merge resolves both the absent-section and omitted-key cases to true while an explicit enabled = false still wins.

Rollback stays one line: [experimental.pgdelta] enabled = false in config.toml, or per-invocation --use-migra (db diff) / --diff-engine migra (db pull). Migra is unchanged. The explicit config rollback is authoritative: the historical SUPABASE_EXPERIMENTAL_PG_DELTA opt-in env var is no longer consulted (with pg-delta on by default it added nothing, and a stale opt-in would have silently defeated enabled = false); --use-pg-delta remains the per-run opt-in that overrides the rollback.

Knock-on behavior changes to note in release notes:

  • the db schema declarative commands' gate (--experimental || pgdelta enabled) is now open by default
  • a versionless db reset --experimental only takes the [db.migrations].schema_paths schema-files path when pg-delta is explicitly disabled; otherwise it replays migrations
  • SUPABASE_EXPERIMENTAL_PG_DELTA is ignored (see Rollback above)

SIDE_EFFECTS.md files, db diff/db pull docs, and the Go CONTRIBUTING pg-delta section were updated to match. Tests pin the new default (absent config → pg-delta), the explicit-false → migra rollback (including with a stale env opt-in present), and the per-invocation flag overrides; migra-subject tests opt out explicitly.

Linked issue

Linear: CLI-2211, CLI-1588

  • The linked issue is open and carries the open-for-contribution label (or I'm a Supabase maintainer).

Checklist

  • The PR title follows Conventional Commits (e.g. fix(cli): …).
  • Tests added or updated for the change.
  • From the repository root, pnpm check:all passes; relevant package tests pass for every touched workspace, and pnpm types:check passes for each touched TypeScript workspace (or workspace declaring it).

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy

…ape hatch (CLI-2211)
The bundled in-process pg-delta engine (formerly "pg-delta next") is now the
only pg-delta implementation. Setting SUPABASE_USE_PG_DELTA_NEXT no longer has
any effect; the temporary opt-out shipped in v2.115.0 is retired as announced
in its release notes.
Removed along with the legacy engine:
- the SUPABASE_USE_PG_DELTA_NEXT flag module and the engine selector layer;
the LegacyPgDeltaEngine service loses its `implementation` discriminator and
every handler branch keyed on it
- the edge-runtime pg-delta Deno script templates, the npm-version pin read
from supabase/.temp/pgdelta-version, and the PGDELTA_NPM_REGISTRY /
PGDELTA_{SOURCE,TARGET}_SSLROOTCERT plumbing (all legacy-engine-only)
- the migrations-catalog cache warmup after db push / db reset / start /
db start / bootstrap, and the whole catalog snapshot machinery
(legacy-pgdelta.cache.ts); the shared migration lister moves to
legacy-migration-list.ts
- the legacy declarative catalog seam (LegacyDeclarativeSeam.exportCatalog),
the pg-delta declarative-apply engine (legacy-pgdelta.apply.ts) and its
unreachable shadow-source sub-branch, and db pull's legacy empty-diff debug
bundle
- the "--strict-coverage has no effect with the legacy pg-delta engine"
warning: the flag is now always effective
SIDE_EFFECTS.md files and db diff/pull docs are updated to match; tests that
exercised the legacy implementation are removed or repointed at the in-process
engine.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
…s (CLI-1588)
An absent [experimental.pgdelta] section (or a section that omits `enabled`)
now resolves to pg-delta for db diff, db pull, and the delegated
db remote commit. Rollback stays a one-liner:
[experimental.pgdelta]
enabled = false
or per-invocation `db diff --use-migra` / `db pull --diff-engine migra`.
- TypeScript config reader: `enabled` defaults to true when absent
- @supabase/config schema + published config.schema.json: default true
- Go binary (delegated db remote changes/commit, db pull --experimental):
the ejected config template now defaults `enabled = true`, so viper's
key-level merge resolves both an absent section and a section without the
key to enabled; `IsPgDeltaEnabled` treats a nil section as enabled. The
init-only PgDeltaInitEnabled flag is gone — the scaffold and the runtime
default are the same value now.
- Knock-on defaults that key off "pg-delta enabled": the declarative schema
commands' gate is open by default (no --experimental needed), and
db reset --experimental only takes the schema-files path when pg-delta is
explicitly disabled.
- The --use-pg-schema deprecation warning now points at the default pg-delta
engine / --use-migra rather than "the default migra engine".
- apps/cli-go/CONTRIBUTING.md scopes the Verdaccio/PGDELTA_NPM_REGISTRY
workflow to the Go binary, which is the only remaining reader.
Existing projects pinned to migra output should set `enabled = false` before
upgrading if they depend on byte-identical migra diffs.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
…CLI-1588)
The declarative commands' gate is open by default now, so the gate-closed
tests seed an explicit [experimental.pgdelta] enabled = false config, and new
tests pin the default-open behavior. The sync recovery-reset tests' fixture
fails apply once instead of always: under the pg-delta default the in-process
recovery reset genuinely replays migrations, so a permanently failing ALTER
made the reset itself fail rather than exercising the recovery flow.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
Migra-subject pull tests opt out explicitly (--diff-engine migra, or
enabled = false when the disabled config state or the declarative alias is
the subject), and new tests pin the flip: no config section -> pg-delta
engine, enabled = false -> migra, --diff-engine migra -> migra despite the
default.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
…ts (CLI-1588)
Migra-subject diff tests opt in with --use-migra; the experimental
schema-files reset tests disable pg-delta explicitly, since that branch now
requires enabled = false. New tests pin the flip on both commands: no config
section -> pg-delta engine (db diff), enabled = false -> migra,
--use-migra override, and an experimental versionless reset without a
pgdelta section replaying migrations instead of schema files.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
gofmt -l flagged pkg/config/db.go and pkg/function/deploy_test.go
(pre-existing whitespace drift from #6253); fixed so the Go CI format check
stays green on branches touching apps/cli-go.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
chmod 0o000 cannot make paths unreadable for root, so the workers-push
unlistable-root test now expects the successful deploy on its
root/listable branch (mirroring its unreadable-source sibling), and the
legacyApplySchemaFiles read-failure test skips under root like reset's own
chmod tests.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
@avallete
avallete requested a review from a team as a code ownerAugust 29, 2026 06:46
@avalleteavallete changed the title refactor: remove legacy pg-delta implementation and next-flag infrastructurefeat(cli): make pg-delta the only and the default diff engineAug 29, 2026
@blacksmith-sh

This comment has been minimized.

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:2f97b70424

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadapps/cli/src/legacy/shared/legacy-migration-list.ts Outdated
Comment threadapps/cli/src/legacy/shared/legacy-migration-list.ts Outdated
@github-actions

github-actionsBot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@1b603b7b25976ebadecb403f7a06ff66c58b5e53

Preview package for commit 1b603b7.

…aults on
With pg-delta enabled by default, the pgcache warmup after
SetupLocalDatabase and migration-down resets started firing in the Go
binary's db start / db reset paths, opening an extra Postgres connection
their pgmock tests never scripted (10s dial timeouts in CI). The catalog it
writes is a legacy-engine artifact with no consumer reachable through the
delegated command surface, and the TypeScript CLI removed its counterpart
in CLI-2211 — remove the two call sites rather than script the connection.
Also pin TestWriteDeclarativeSchemas to the explicitly-disabled state its
schema_paths config write is now gated on.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvBVkSd9Wy
Narrow the not-found read error with Predicate.isTagged instead of
reading ._tag directly, and rewrite the module's comments in terms of
the legacy shell's own established behavior instead of Go citations.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
@avalleteClaude

Copy link
Copy Markdown
MemberAuthor

CI status note — Run end-to-end tests (shard 2/3) failure is not this PR's.

The failing test is packages/stack tests/createStack.e2e.test.ts: its beforeAll times out after 45s inside createStack({...}) (before stack.start()), followed by the afterAll 30s timeout. It failed identically on this PR's last two heads — and also on the unrelated #6371 (workers push, run 33230852020, where all three e2e shards failed with the exact same createStack.e2e.test.ts:24 / :44 hook timeouts).

Why it's not this PR's:

  • This diff touches apps/cli, apps/cli-go, and packages/config. packages/stack depends only on @effect/* and @supabase/process-compose — not @supabase/config — and neither stack nor process-compose is touched here.
  • The last green e2e run was Aug 28 17:28 UTC (run 4834); every test.yml run since then shows failures across unrelated branches, and nothing touching packages/stack merged to develop in that window (only CI-workflow commits).

No fix PR exists yet that I can port. A fresh run (33239773281) is already in progress on the current head 64831cd and serves as the re-run; I'll keep watching it. All other failures from the previous run are resolved: the 14 Go test failures were fixed in 4234d36, and the "Run unit and integration tests" red on the old head was unit=success, integration=cancelled — cancellation from the superseding push, not a test failure.


Generated by Claude Code

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:64831cdca5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadapps/cli/docs/supabase/db/diff.md
Comment threadapps/cli-go/CONTRIBUTING.md
Comment threadapps/cli/src/legacy/shared/legacy-db-config.toml-read.ts
Comment threadapps/cli/src/legacy/shared/legacy-db-config.toml-read.ts
@avalleteClaude

Copy link
Copy Markdown
MemberAuthor

CI status note (2/2) — Run end-to-end tests (shard 3/3) failure is also not this PR's.

The failing test is apps/cli src/next/commands/start/start.e2e.test.ts:67 ("keeps an HTTP service dormant until its first proxied request"): supabase start exits 1 with stdout ending at postgres: Initializing.... The unrelated #6371 failed with the identical test and assertion (start.e2e.test.ts:67, expected 1 to be +0) in run 33230852020. src/next/ has no pg-delta code paths, so this diff cannot reach it.

Together with the shard 2/3 createStack hook timeout (see previous note), both point at the same underlying repo-wide breakage: local Docker stack provisioning failing in CI since Aug 28 ~18:00 UTC, on every branch. No fix exists yet to port. Everything within this PR's control is green-bound; these two e2e checks will stay red until the base breakage is fixed.


Generated by Claude Code

…ne docs
Address AI review findings on the default-engine flip:
- `[experimental.pgdelta] enabled = false` now always selects migra: the
historical SUPABASE_EXPERIMENTAL_PG_DELTA opt-in env var is no longer
consulted (TS engine resolution and the Go delegated surface alike). With
pg-delta on by default the opt-in added nothing, and honoring a stale one
silently defeated the documented config rollback. The now-unused
`envLookup` config accessor is removed with its last consumers.
- db diff docs no longer open by claiming migra runs by default; the intro
describes the pg-delta default with migra as the containerized fallback.
- The Go CONTRIBUTING Verdaccio workflow now demonstrates a delegated
command (`db pull --experimental` / `db remote commit`) instead of an
ordinary `db pull`, which runs the TS in-process engine and ignores
PGDELTA_NPM_REGISTRY.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQAoY9JF4uiZRvKVkSd9Wy
Sign up for freeto 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.

2 participants

@avallete@claude