Skip to content

feat(cli): enable pg-delta by default for new projects#5511

Merged
avallete merged 7 commits into
developfrom
claude/relaxed-planck-TX3jl
Jun 12, 2026
Merged

feat(cli): enable pg-delta by default for new projects#5511
avallete merged 7 commits into
developfrom
claude/relaxed-planck-TX3jl

Conversation

@avallete

@avallete avallete commented Jun 8, 2026

Copy link
Copy Markdown
Member

First non-breaking step of CLI-1586 toward making pg-delta the default diff engine. New projects opt into pg-delta, and db pull now lets the configured engine drive its shadow diff. Existing projects are unaffected.

New projects default to pg-delta (CLI-1587)

supabase init now scaffolds config.toml with [experimental.pgdelta] enabled = true. The global default for an absent/undefined section stays migra, so existing projects are untouched and enabled = false remains a one-line rollback.

The Go config template doubles as the source of programmatic defaults via mergeDefaultValues (it ejects the same template), so literally enabling pg-delta in the template would have flipped the default for every existing config. To keep this non-breaking, the enabled value is templated from an init-only flag PgDeltaInitEnabled:

  • InitConfig sets it from InitParams.UsePgDelta, which is opted in only by the supabase init command and bootstrap. Other InitConfig callers — including the WriteConfig test helper — leave it false, so they keep producing migra-default configs.
  • It is false when Eject feeds mergeDefaultValues, so configs without the section keep resolving to migra.

Scoping the opt-in to the command (rather than unconditionally inside InitConfig) keeps the generated default from leaking into the global utils.Config during tests that scaffold a config, which would otherwise change unrelated db start behavior.

The TS init template (project-init.templates.ts) writes enabled = true directly and stays byte-aligned with the Go scaffold (enforced by the existing parity test).

db pull engine resolution

When pg-delta is enabled (config or EXPERIMENTAL_PG_DELTA), supabase db pull keeps its migration-file workflow but defaults the shadow diff engine to pg-delta instead of migra. Specifically:

  • The migration-file workflow is preserved; enabling pg-delta in config does not switch db pull to declarative output.
  • The shadow diff engine default follows whether pg-delta is active, via the extracted, unit-tested helper resolvePullDiffEngine.
  • An explicit --diff-engine migra (or enabled = false) is an authoritative rollback that overrides the config default.
  • Declarative schema export remains opt-in via the --declarative flag; --use-pg-delta is kept as a deprecated alias whose message guides users to --declarative with [experimental.pgdelta] enabled = true.

db diff engine resolution

resolveDiffEngine (unit-tested) centralizes the decision: the config default applies unless an explicit non-pg-delta engine flag (--use-migra, --use-pgadmin, --use-pg-schema) is selected, which clears pg-delta mode so diff.Run skips pg-delta-specific declarative shadow setup and the PGDELTA_DEBUG path. The deprecated db remote commit is intentionally left unchanged.

Notes for reviewers

  • PgDeltaInitEnabled is toml:"-" json:"-", so it is never parsed from or serialized to config files — it only feeds template rendering.
  • The TS --diff-engine flag is optional and only forwarded when set, so the Go config-driven default applies when omitted; no TS behavior change was needed.
  • --declarative / --use-pg-delta are mutually exclusive with --diff-engine.
  • Restored the auto_expose_new_tables template comment to the develop wording after a rebase had reverted it.
  • Docs updated: db diff / db pull reference pages and the pull SIDE_EFFECTS.md.

Closes CLI-1587

https://claude.ai/code/session_014k7CJwuyg5BBeQxTHHWWJY

@blacksmith-sh

This comment has been minimized.

@avallete avallete marked this pull request as ready for review June 9, 2026 12:17
@avallete avallete requested a review from a team as a code owner June 9, 2026 12:17

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 9ca7ba83d4

ℹ️ 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 thread apps/cli-go/pkg/config/templates/config.toml
Comment thread apps/cli-go/pkg/config/templates/config.toml
Comment thread apps/cli/src/shared/init/project-init.templates.ts
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Supabase CLI preview

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

Preview package for commit 2b8d306.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 27208348653

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.2%) to 64.547%

Details

  • Coverage increased (+0.2%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 235 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

235 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
internal/db/declarative/declarative.go 147 55.18%
cmd/db.go 83 48.81%
internal/utils/git.go 5 53.33%

Coverage Stats

Coverage Status
Relevant Lines: 16275
Covered Lines: 10505
Line Coverage: 64.55%
Coverage Strength: 7.11 hits per line

💛 - Coveralls

Reapply PR #5511 on current develop after resolving unrelated-history
conflicts. Scope pg-delta init default to supabase init/bootstrap only,
keep db pull on migration output with config-driven shadow diff engine,
honor explicit --use-migra for db diff, keep db remote commit on
migration files, and extend the TS/JSON config schema with pgdelta.
@avallete avallete force-pushed the claude/relaxed-planck-TX3jl branch from 1e4b018 to 80b2d7f Compare June 11, 2026 14:36

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 80b2d7f559

ℹ️ 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 thread apps/cli-go/cmd/db.go Outdated
db diff resolved useDelta from the config-driven default and only let
--use-migra override it. In a pg-delta-enabled project, --use-pg-schema
(or --use-pgadmin) selected its differ but left useDelta true, so
diff.Run still ran pg-delta declarative shadow setup and the
PGDELTA_DEBUG path. Extract resolveDiffEngine so any explicit non-delta
engine clears pg-delta mode, and cover it with unit tests.

Also reflow go-cli-porting-status.md to satisfy oxfmt.

https://claude.ai/code/session_014k7CJwuyg5BBeQxTHHWWJY

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: ff09fd2deb

ℹ️ 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 thread apps/cli-go/cmd/db.go
Comment thread apps/cli-go/cmd/db_pull_routing_test.go
Comment thread apps/cli-go/internal/bootstrap/bootstrap.go
Comment thread apps/cli-go/cmd/db.go Outdated
Comment thread apps/cli-go/pkg/config/templates/config.toml Outdated
Comment thread apps/cli/src/legacy/commands/db/pull/pull.command.ts Outdated
Comment thread apps/cli/src/shared/init/project-init.templates.ts Outdated
Comment thread apps/cli-go/pkg/config/templates/config.toml
claude added 2 commits June 11, 2026 15:40
- Restore the auto_expose_new_tables comment block to the develop wording
  in both the Go config template and the TS init template; a rebase had
  reverted it to an older revision.
- Make the deprecated --use-pg-delta pull flag guide users to
  "--declarative with [experimental.pgdelta] enabled = true", in both the
  Go cobra deprecation message and the TS flag description.

https://claude.ai/code/session_014k7CJwuyg5BBeQxTHHWWJY
Hardcode [experimental.pgdelta] enabled = true in the config template
instead of gating it behind an init-only flag. Because mergeDefaultValues
ejects the template as the default layer, this makes pg-delta the active
engine for every project that does not explicitly opt out, not just newly
generated ones. Drop the PgDeltaInitEnabled flag and the InitParams
UsePgDelta plumbing in init and bootstrap.

Disable pg-delta in the db start / start test suites: catalog caching
shells out to a subprocess that cannot use the in-process pgmock dialer,
and those suites cover container/schema startup rather than caching.

https://claude.ai/code/session_014k7CJwuyg5BBeQxTHHWWJY
@avallete avallete changed the title feat(cli): enable pg-delta by default for new projects feat(cli): make pg-delta the default diff engine Jun 11, 2026
@avallete avallete changed the title feat(cli): make pg-delta the default diff engine feat(cli): enable pg-delta by default for new projects Jun 11, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 6c73392384

ℹ️ 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 thread apps/cli-go/pkg/config/templates/config.toml Outdated
@avallete avallete enabled auto-merge June 12, 2026 10:34
@avallete avallete added this pull request to the merge queue Jun 12, 2026
Merged via the queue into develop with commit e790eb3 Jun 12, 2026
22 checks passed
@avallete avallete deleted the claude/relaxed-planck-TX3jl branch June 12, 2026 10:43
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