feat(cli): default database workflows to the bundled pg-delta engine - #6102
feat(cli): default database workflows to the bundled pg-delta engine#6102avallete wants to merge 43 commits into
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@f7e27f1e5613a40d486e914cc0a775d5d3a3d57dPreview 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: db045256e7
ℹ️ 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".
…lta-next # Conflicts: # apps/cli/src/legacy/commands/bootstrap/SIDE_EFFECTS.md # apps/cli/src/legacy/commands/db/diff/SIDE_EFFECTS.md # apps/cli/src/legacy/commands/db/diff/diff.handler.ts # apps/cli/src/legacy/commands/db/diff/diff.integration.test.ts # apps/cli/src/legacy/commands/db/pull/SIDE_EFFECTS.md # apps/cli/src/legacy/commands/db/pull/pull.handler.ts # apps/cli/src/legacy/commands/db/pull/pull.integration.test.ts # apps/cli/src/legacy/commands/db/schema/declarative/declarative.flow.ts # apps/cli/src/legacy/commands/db/schema/declarative/generate/SIDE_EFFECTS.md # apps/cli/src/legacy/commands/db/schema/declarative/generate/generate.layers.ts # apps/cli/src/legacy/commands/db/schema/declarative/sync/SIDE_EFFECTS.md # apps/cli/src/legacy/commands/db/schema/declarative/sync/sync.layers.ts # apps/cli/src/legacy/commands/db/shared/legacy-pgdelta.seam.layer.ts # apps/cli/src/legacy/commands/db/start/start.handler.ts # apps/cli/src/legacy/shared/legacy-db-config.toml-read.ts # apps/cli/src/legacy/shared/legacy-migration-apply.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cea474d0b2
ℹ️ 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: 23814e76d7
ℹ️ 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".
- read the declarative export manifest only under the next engine, so a stale or malformed .pgdelta-export.json can no longer break the SUPABASE_USE_PG_DELTA_NEXT=false escape hatch - surface planSchemaFiles skipped statements as coverage diagnostics: warned by default, blocking under --strict-coverage - warn when a manifest-less declarative directory keeps unmanaged files the next writer cannot prune, advising a clean regenerate - converge pg_net in both directions: PG14 db reset now runs the same drop-before-conditional-create as fresh setup, and start-on-existing- volume drops pg_net when webhooks are disabled unless an applied migration installed it - gate the schema_paths transition warning on the resolved next engine; migra and the legacy opt-out still substitute declared-schema targets - warn once when --strict-coverage is ignored by the legacy engine - redact unparseable connection strings with the shared redactor instead of a naive :password@ regex - record deferred symlink/port-allocation findings in docs/roadmap/pg-delta-next-follow-ups.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: a621690aff
ℹ️ 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: c3c4643150
ℹ️ 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: b2b7cb9ebb
ℹ️ 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".
…lta-next # Conflicts: # apps/cli/src/legacy/shared/db-bootstrap/container-lifecycle.ts # apps/cli/src/legacy/shared/db-bootstrap/container-lifecycle.unit.test.ts # apps/cli/src/legacy/shared/db-bootstrap/docker-create-args.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2cc84ab035
ℹ️ 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".
- Normalize trailing separators (and trailing '.' segments) in legacyResolveStagedDeclarativeDir so a configured declarative_schema_path like './schemas/' stages a sibling './schemas-next' instead of nesting '-next' inside the active tree, where the printed rm -rf adoption command would destroy both copies. - Harden the sync staging guard to reject any staged directory that resolves inside the active declarative directory, not just equality. - Gate describeDockerLive on the configured live environment as well as the Docker probe, so live suites stay inert on machines that merely expose Docker; document the gate in AGENTS.md. - Record the TS-only --strict-coverage flag in go-cli-divergences.md. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
CodeQL flagged the trailing-separator regex for ambiguous nested quantification (potential exponential backtracking on long separator runs). Trim trailing separators and '.' segments with an explicit linear scan instead; behavior is unchanged and covered by the same unit tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Dogfooding follow-up for the pg-delta next compatibility gates: - Both gates (shadow-load failure and plan-refuse) now render one shared template: diagnosis + evidence + an explicit do-not-apply hazard line, with the staged-upgrade commands carried on the error's suggestion so Output.fail prints them instead of the generic 'rerun with --debug' footer. A deliberate gate no longer reads as a crash. - Non-interactive runs get exactly one recommended recovery (the staged regenerate). The extension.sql alternative was a false trail there: each hand-added declaration only unlocks the next refusal. - Interactive prompts keep repair as an advanced choice labelled with the full <declarative_schema_path>/extension.sql path and a 'may surface another gap' hint, and the repair gate now also offers the staged export as the recommended option. - db pull in-sync keeps Go's message and non-zero exit but replaces the debug footer with an explanatory suggestion; recorded as a deliberate divergence 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: f7e27f1e56
ℹ️ 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".
|
|
||
| /** Default declarative schema dir. */ | ||
| const DEFAULT_DECLARATIVE_DIR_SEGMENTS = ["supabase", "database"] as const; | ||
| const DEFAULT_DECLARATIVE_DIR_SEGMENTS = ["supabase", "schemas"] as const; |
There was a problem hiding this comment.
Preserve the previous default for existing declarative trees
When an existing project generated its declarative schema under the former default supabase/database and omitted declarative_schema_path, this unconditional default switch makes generate/sync look only in supabase/schemas. A non-interactive sync now reports no schema, while --yes can generate a replacement tree from the selected database and silently ignore edits that existed only in the old declarative tree. Detect the former default when it already exists or provide an explicit migration rather than abandoning the established filesystem input.
AGENTS.md reference: apps/cli/AGENTS.md:L288-L294
Useful? React with 👍 / 👎.
| const adoptionCommand = (declarativeDir: string, stagedDir: string): string => | ||
| ` rm -rf ${shellQuoteArgument(declarativeDir)} && mv ${shellQuoteArgument(stagedDir)} ${shellQuoteArgument(declarativeDir)}`; |
There was a problem hiding this comment.
Reject adoption paths that contain project metadata
When declarative_schema_path resolves to the supabase directory itself—for example, the documented under-supabase setting is "."—the staged recovery command becomes rm -rf supabase && mv supabase-next supabase. Following the command printed by either compatibility gate deletes config.toml, all migrations, seeds, and other project metadata before replacing the directory with only the staged export. Refuse declarative roots that contain these protected project files before emitting or executing this adoption flow.
AGENTS.md reference: apps/cli/AGENTS.md:L288-L294
Useful? React with 👍 / 👎.
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.40and@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.