feat(cli): default database workflows to the bundled pg-delta engine - #6102
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8078b53b04
ℹ️ 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".
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@509f6a9d23e83d2e88d459b746c522752c7c49e2Preview package for commit |
|
Provisioned validation against exact head
The labeled dispatch check itself cannot reach the internal repository because its GitHub App is not installed there, so this run was dispatched manually against the same SHA. |
There was a problem hiding this comment.
💡 Codex Review
When a multi-segment pg-delta plan is generated in the same second as an existing migration with a different name—or overlaps future-dated segments from a prior run—checking only w.path misses the collision because the filenames differ. This writes multiple files with the same 14-digit version; local migration loading accepts both, but schema_migrations.version is a primary key, so a pull can fail while repairing history and later push/reset operations can fail while applying the duplicate version. Check every candidate version against all existing migration filenames rather than only the generated pathname.
ℹ️ 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".
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4861957ee
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
When a multi-unit plan assigns a version already used by another migration with a different name, this exact-path check reports no collision and writes a second <same-version>_*.sql file. This can occur when a migration was created in the same second as the pull/diff, or when a later plan unit's future-dated timestamp overlaps an existing file; db pull then upserts that version in schema_migrations, replacing the existing history row while both local files remain. Check for any ${version}_*.sql entry before accepting the generated set, rather than only each proposed pathname.
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e912767ba6
ℹ️ 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".
- Warn when a declarative tree still lives under the former supabase/database default while declarative_schema_path is unset and the new supabase/schemas default is empty, so upgraded projects are told how to keep their existing tree instead of silently regenerating elsewhere. - Rename db schema declarative generate --output/-o to --output-dir (no short alias): the legacy root reserves --output/-o for the global machine-format flag, and the leaf string flag shadowed it, turning 'generate -o json' into a write to a directory named json. Recorded in docs/go-cli-divergences.md. - Render the staged-upgrade recovery commands for the host platform: single-line PowerShell (Remove-Item/Move-Item) on Windows, unchanged rm -rf/mv elsewhere, so the printed destructive commands run as printed. - The interactive staged export now states it snapshots the running local database and offers the same reset-to-migrations prompt as the smart-target local path before exporting. - Align the skipped-statement diagnostics comment with actual behavior: the raw statement is deliberately carried verbatim (user-local content); no redaction is claimed or attempted. - Document the pg_net/[experimental.webhooks] convergence tradeoffs in the start/db start SIDE_EFFECTS and the divergence ledger, including the accepted Studio-installed-pg_net edge. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ELeyDSbDjNbFzQ6kLKdxnQ
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b63da43e73
ℹ️ 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".
…layer The production engine layer reimplemented the tested generic selector inline via a private helper with a hand-maintained requirement union. Generify the selector over its layers' requirements and delegate, so one code path resolves and logs the implementation choice. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nary The fixture imported @supabase/pg-topo eagerly, but production only reaches it through the literal dynamic import inside pg-delta's dist/frontends/sql-order.js. Route the fixture through analyzeForShadow so the compile test proves Bun traces that dynamic import and embeds the WASM asset for the real import shape. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ec1fb8b7b2
ℹ️ 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".
…hadow Explicit-mode endpoint resolution is left-to-right and stateful: a linked endpoint re-merges [remotes.<ref>] into the mutable cfg. The migrations endpoint already honored that order for projectRef but diffExplicit received the final cfg, so --from migrations --to linked built the migrations shadow/catalog with the remote-merged webhooks, vault, API-expose, and password baseline. Snapshot cfg when the first migrations endpoint resolves and pass that snapshot as toml, covering both engines at the handler seam. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9421d96bb
ℹ️ 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".
The previous drift fix ran against a stale oxfmt install; the pinned 0.61.0 (and CI) want the original formatting. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The engine layer treats an empty shell SUPABASE_USE_PG_DELTA_NEXT as present (godotenv parity), but push and the db-setup warmup resolved the same flag through envLookup, which treats an empty shell value as unset — so one project could warm the legacy catalog on push while diff/pull/generate/sync ran the next engine. Hoist the presence-aware combinator into legacy-pgdelta-next-flag.ts as the single source of truth and use it at every call site. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Remove-Item errors are non-terminating, so the printed PowerShell recovery line would still run Move-Item after a failed removal and could move the staged export inside the still-existing active tree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f06ab1038
ℹ️ 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".
Explicit --from/--to URL endpoints on the next engine parsed against process.env only, so PGPASSWORD/PGSSLMODE/PGPASSFILE kept in supabase/.env worked with --db-url but failed with an explicit URL. Hoist the shell-over-project lookup into legacyLayeredParseEnv, adopt it in the --db-url resolver, and thread context.projectEnv through acquireDatabase into endpoint parsing. Shadow URLs keep the plain process env: they are CLI-generated with embedded credentials. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adopts the new default flat export layout: one directory per schema at the declarative root with cluster-level objects under _cluster/, so the default tree becomes supabase/schemas/public/... instead of the doubled supabase/schemas/schemas/public/... The writer was already layout-agnostic, so only next-engine fixtures, docs, and the pins change; the legacy opt-out engine stays on the pinned alpha.33 nested layout, recorded in go-cli-divergences.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b32909a9b5
ℹ️ 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".
The legacy Edge Runtime catalog warmup after push, start, db start, and reset is additionally gated on SUPABASE_USE_PG_DELTA_NEXT resolving to the legacy engine; the default next engine skips it. The four SIDE_EFFECTS.md checklists still said the catalog is written whenever pg-delta is enabled and omitted the env var. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Bundles
@supabase/pg-deltaand@supabase/pg-topointo the CLI and makes the in-process engine the default for pg-delta-backeddb diff,db pull, and the declarative schema workflows (db schema declarative generate|sync). The legacy edge-runtime implementation remains available as an explicitSUPABASE_USE_PG_DELTA_NEXT=falseopt-out; there is no automatic fallback or runtime package download — a next-engine failure propagates instead of silently switching implementations.This branch is reconciled with the TypeScript database-command port on
develop:db diff --use-pg-schemaremains the sole Go delegation--project-refresolution stays in the TypeScript command path and is rejected for delegated modes that cannot honor it<declarative_schema_path>-nextdirectory (never inside the active tree — trailing separators in the configured path are normalized, and staging into or under the active directory is rejected) and prints adoption commands built from the configured pathdb pullwhen already in sync keeps Go's "No schema changes found" message and non-zero exit, but replaces the debug footer with an explanatory suggestion (recorded ingo-cli-divergences.md)transaction=falsedirective so later push, reset, and up operations keep those plans outside CLI-owned transactionspg_netwhile local webhooks are disabled now surface targeted guidance to enable[experimental.webhooks]Default-engine snapshots, plans, and diagnostics use an isolated v2 artifact layout. Extraction errors are refused; coverage gaps warn by default and can be promoted to failures with
--strict-coverageondb diff,db pull, and the declarative commands (a TS-only flag, recorded indocs/go-cli-divergences.md). Generated SQL and file segmentation may differ from the legacy renderer — the compatibility contract is successful execution and convergence on a subsequent diff.The branch pins published
@supabase/pg-delta@1.0.0-alpha.41and@supabase/pg-topo@1.0.0-alpha.5from the npm registry, and patches the libpg-query parser packaging so the WASM asset is embedded in compiled Bun binaries (with an integration test verifying the patched asset survives compilation).A live local-convergence suite (
legacy-pgdelta-next.live.test.ts) exercises the next engine against a real Docker stack. It is gated on the configured live environment plus a Docker probe (describeDockerLive), so it runs only under the cli-e2e-ci harness — machines that merely expose Docker stay inert.The earlier dogfooding playbook, ADR, and glossary documents were trimmed out of this PR to keep it scoped to the engine change. Linked-project, TLS-required, and pooler/SNI acceptance still needs a provisioned data-plane environment because the shared live harness does not create project Postgres.