Skip to content

fix(cli): remove db schema declarative __catalog seam for migrations mode (CLI-1959) - #6061

Merged
Coly010 merged 3 commits into
developfrom
columferry/cli-1959-remove-the-db-schema-declarative-__catalog-seam-via-native
Aug 6, 2026
Merged

fix(cli): remove db schema declarative __catalog seam for migrations mode (CLI-1959)#6061
Coly010 merged 3 commits into
developfrom
columferry/cli-1959-remove-the-db-schema-declarative-__catalog-seam-via-native

Conversation

@Coly010

@Coly010 Coly010 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

What changed

Replaces the hidden Go seam db schema declarative __catalog --mode migrations — used by db diff --from/--to migrations and db schema declarative sync's migrations-catalog diff source — with native TypeScript catalog export, invoking pg-delta directly via the already-shipped legacyExportCatalogPgDelta edge-runtime path instead of proxying through the Go binary.

baseline/declarative catalog modes remain seam-backed (out of scope here — they need native shadow-provisioning primitives that are CLI-1956's territory, a separate in-progress issue). LegacyCatalogMode is narrowed to "baseline" | "declarative", making the remaining Go-backed surface exhaustive/compile-checked.

Bundled parity fix: the old code routed db diff --from migrations through the wrong Go-equivalent function — one shaped for declarative.go's semantics (setup-token-folded cache key, zero-migrations→baseline reuse, a Creating shadow database... stderr line) — when Go's actual db diff path uses explicit.go's resolveMigrationsCatalogRef (bare migration-hash cache key, no stderr line, always consults cache). This meant db diff --from migrations could never reuse a cache warmed by db push, and printed a spurious progress line. Both are fixed. The generated SQL was unaffected (a zero-migration catalog and the platform baseline are the same snapshot by Go's own logic) — this was a caching-efficiency and stderr-parity bug, not a correctness bug in the diff output.

Why

Part of the M9 "Go removal" milestone. This is the last piece of legacy-pgdelta.seam.layer.ts's exportCatalog surface that doesn't need shadow-provisioning primitives from CLI-1956.

Review notes

Reviewed independently by go-parity-auditor, engineer-reviewer, and architect-reviewer (all approved after a follow-up commit). Findings addressed:

  • Added test coverage for the previously-untested dominant real-world path (sync with local migrations present, cache hit/miss, --no-cache), including the Creating shadow database... stderr-parity assertions — all verified load-bearing via mutation checks.
  • Extracted shared logic between the two new cache-key/path-resolution helpers and fixed a parameter-order inconsistency between sibling functions that could have caused a silent, permanent cache miss.
  • Exported LegacyBaselineTomlConfig (was duplicated as an inline structural type) and corrected the module header, which had gone stale (the file now also owns shadow-provisioning orchestration, not just pure cache-key derivation).

Fixes CLI-1959

Coly010 added 2 commits August 4, 2026 15:38
…mode via native pg-delta export (CLI-1959)

db diff's explicit --from/--to migrations, and db schema declarative sync's
migrations-catalog diff source, resolved through the hidden Go seam
db schema declarative __catalog --mode migrations. Replace both with native
TypeScript resolution: the existing db __shadow --mode diff seam (unchanged,
CLI-1956 scope) provisions the shadow, and the already-native
legacyExportCatalogPgDelta exports its catalog, cached with the same
byte-stable Go cache-key scheme pg-delta caching already uses elsewhere.

db diff and db schema declarative sync use two different, intentionally
distinct Go cache-key schemes here (bare migrations hash vs. a setup-inputs-
folded hash) — legacyResolveMigrationsCatalogRef and
legacyGetMigrationsCatalogRef mirror Go's explicit.go/declarative.go
functions respectively; see their doc comments.

"baseline" and "declarative" catalog modes (db schema declarative
generate/sync) still go through the Go seam: they need a shadow provisioned
with only the platform baseline, or with declarative files applied, neither
of which has a native TS port yet (tracked by CLI-1956/CLI-1823).
LegacyCatalogMode is narrowed to drop "migrations" accordingly.
… (CLI-1959)

Three reviewers converged on the same gaps in the prior commit's native
migrations-catalog resolution:

- Cover the dominant real-world code path (project with local migrations,
  cache enabled) for `legacyGetMigrationsCatalogRef`, which was previously
  only exercised via the zero-migrations branch. Also pin the stderr
  asymmetry between `db diff --from/--to migrations` (no "Creating shadow
  database..." line) and `db schema declarative sync` (prints it) that this
  port's parity fix depends on.
- Deduplicate the two catalog-path resolvers' scan loop into a shared
  `resolveLatestByFamily` helper, and normalize `legacyResolveDeclarativeCatalogPath`
  to the same Go-faithful `(hash, prefix)` parameter order as its sibling
  `legacyResolveMigrationCatalogPath` (the two previously took the opposite
  order, a silent-cache-miss footgun on a swap). Extract the shared
  shadow-provision/export/persist/cleanup mechanics behind
  `legacyResolveMigrationsCatalogRef` and `legacyGetMigrationsCatalogRef`
  into `exportViaShadowCatalog`.
- Export `LegacyBaselineTomlConfig` from `legacy-db-config.toml-read.ts`
  instead of re-declaring its shape inline in `legacyResolveSetupInputs`,
  and update `legacy-pgdelta.cache.ts`'s module header to reflect that it
  now also owns shadow provisioning and a stderr side effect.
@Coly010

Coly010 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Coly010 Coly010 self-assigned this Aug 5, 2026
@Coly010
Coly010 marked this pull request as ready for review August 5, 2026 08:52
@Coly010
Coly010 requested a review from a team as a code owner August 5, 2026 08:52
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@4feb890a791b2cabd89a00a1e8e7c1c188f00694

Preview package for commit 4feb890.

@Coly010
Coly010 added this pull request to the merge queue Aug 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Aug 5, 2026
pull Bot pushed a commit to oogalieboogalie/cli that referenced this pull request Aug 5, 2026
…audit (CLI-1967) (supabase#6074)

## What

Doc/comment-accuracy sweep from
`apps/cli/docs/go-parity-audit-2026-07-24.md` §6 (untracked locally, not
part of this repo). No runtime behavior changes — every item below was
independently re-verified against current Go (`apps/cli-go/`) and TS
source before fixing, since the audit is 12 days old and several items
had drifted further in that time (in both directions).

## Fixed

- **`docs/go-cli-porting-status.md`** — `functions list` legacy-shell
status `wrapped` → `ported` (verified: zero `LegacyGoProxy` refs).
`functions download` status corrected the other way, `ported` →
`wrapped` (its handler still delegates wholesale via `LegacyGoProxy` for
the default `--use-docker` path; only `--use-api` is native — noted as a
hybrid in the row). Added a `ported` definition to the legacy-status
legend (it only defined `wrapped`/`missing`, despite `ported` being ~90%
of rows) and retitled that section from "Legacy Shell Wrapping Status"
to "Legacy Shell Command Status" to match. Fixed the adjacent `functions
delete/deploy/list/new/serve` legacy-shell notes, which all still said
"Wrapped in legacy shell" despite being natively ported.
- **`legacy-pgdelta.seam.service.ts`** — fixed two stale doc comments
(`execInherit`, `ensureLocalDatabaseStarted`) that referenced things as
"not yet ported" when they now are (`db reset`, `start`/`db start`). Did
**not** touch `exportCatalog`'s doc comment / `LegacyCatalogMode`, which
the audit also flagged — that exact hunk is already being rewritten more
completely by the in-flight CLI-1959 PR (supabase#6061, open); fixing it here
would guarantee a conflict with a strictly better version.
`legacy-db-bootstrap.seam.service.ts` (the audit's other named file) was
checked and found already accurate — CLI-1954/1955 (native `db
start`/`db reset --local`) are still unmerged, so its "not yet ported"
claim is currently true.
- **`network-restrictions/{get,update}/SIDE_EFFECTS.md`** — the `-o
{json,yaml,toml,env}` sections previously implied Go itself produces
distinct byte-identical output per format. Verified against Go source:
`restrictions/get`/`update` never read `OutputFormat` at all — they
always print the same 3-line `fmt.Printf` template regardless of `-o`.
Corrected both docs to state this plainly, documented that TS's
format-specific output here is a deliberate TS-only enhancement with no
real Go behavior to match (including no Go casing convention, since TS
uses the map-shaped encoders rather than CLI-1975's struct-spec ones),
and trimmed the resulting repetition.
- **`inspect/report/SIDE_EFFECTS.md`** — added the empty/no-file
divergence on `COPY` failure: Go's `copyToCSV` opens the output file
with `O_TRUNC` before running the query, so a failing query still leaves
a file (empty or partial); TS buffers in memory and only writes on
success, leaving no file on a fresh run — and leaving the *previous*
run's stale CSV in place on a same-day re-run (the more consequential
case). Cross-referenced from `legacy-db-connection.errors.ts`'s
`LegacyDbCopyError` doc comment, which already covered the message-text
angle of the same divergence.
- **`domains.cname.ts`** — the comment describing Go's CNAME "failed to
locate" error dump wrongly implied Go embeds readable JSON. Verified
against Go source and empirically (compiled the equivalent locally): Go
JSON-marshals the answers to a `[]byte`, then formats that `[]byte` with
`%+v`, which Go's `fmt` renders as an uncapped decimal byte-value array,
not the JSON text — a `%+v`-on-`[]byte` footgun, not an intended format.
Fixed both the function's JSDoc and the inline comment (they'd
contradicted each other after an earlier pass), and cross-referenced the
divergence from `domains/SIDE_EFFECTS.md`.
- **`branches/orgs/projects/secrets` SIDE_EFFECTS `-o toml`/`-o yaml`
claims**, **`functions deploy`'s `NPM_AUTH_TOKEN` env table entry**, and
**`update-root-key.handler.ts`'s color comment** — all already fixed by
CLI-1975 (supabase#6002), CLI-1985 (supabase#6005), and CLI-1990 (supabase#5978) respectively,
which merged after the audit ran. Verified current state matches; no
changes needed.
- **`start/SIDE_EFFECTS.md`'s `--ignore-health-check` ruling** — already
fully handled by CLI-1987 (supabase#6007, merged), whose own description
explicitly says CLI-1967 should not re-document it. Left untouched.

## Left as noted, not fixed (out of scope for a docs-only pass)

- The `network-restrictions get`/`update` TS-only `-o` support is a
real, pre-existing behavioral divergence from Go (Go has no such
behavior at all for these two commands) — documented accurately here,
but whether it should be *removed* to enforce strict parity is a ruling
this PR doesn't make.
- `docs/go-cli-porting-status.md`'s "Functions" section (next/-shell
table) has a larger, pre-existing inaccuracy discovered while fixing the
adjacent legacy-shell notes: it claims there's "still no dedicated
`functions` CLI surface" in `next/`, but `next/commands/functions/`
already exists (list/delete/deploy/download/new/dev, registered in
`next/cli/root.ts`). Added command-path links and flagged the section as
needing its own flag-by-flag parity audit rather than silently
reclassifying rows without one.

Fixes CLI-1967
…9-remove-the-db-schema-declarative-__catalog-seam-via-native

# Conflicts:
#	apps/cli/src/legacy/commands/db/diff/SIDE_EFFECTS.md

@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: 4feb890a79

ℹ️ 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/src/legacy/commands/db/shared/legacy-pgdelta.cache.ts
@Coly010
Coly010 added this pull request to the merge queue Aug 6, 2026
Merged via the queue into develop with commit d6a845b Aug 6, 2026
21 checks passed
@Coly010
Coly010 deleted the columferry/cli-1959-remove-the-db-schema-declarative-__catalog-seam-via-native branch August 6, 2026 10:49
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.

2 participants