Skip to content

fix(cli): print declarative-schema-written line in sync bootstrap (CLI-1980) - #5971

Open
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1980-db-schema-declarative-sync-bootstrap-omits-the-declarative
Open

fix(cli): print declarative-schema-written line in sync bootstrap (CLI-1980)#5971
Coly010 wants to merge 1 commit into
developfrom
columferry/cli-1980-db-schema-declarative-sync-bootstrap-omits-the-declarative

Conversation

@Coly010

@Coly010 Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What changed

On the db schema declarative sync bootstrap path (no declarative files present → the CLI offers to generate them), the TS handler generated, wrote, and catalog-warmed the declarative schema but never told the user where the files were written. Go's bootstrap delegates to declarative.Generate, which prints Declarative schema written to <dir> to stderr after the write and the catalog warm (apps/cli-go/internal/db/declarative/declarative.go:133→138-155→156, reached via cmd/db_schema_declarative.go:389→366).

The sync bootstrap now emits that line:

  • after legacyWriteDeclarativeSchemas and the catalog warm, matching Go's ordering;
  • on both the interactive-accept and --yes/SUPABASE_YES paths (Go prints it in both);
  • regardless of --no-cache (Go's print sits outside the if !noCache warm gate — the warm is skipped, the line is not);
  • printing the relative dir, exactly what Go's utils.GetDeclarativeDir() returns (the declarative_schema_path config value — already supabase/-prefixed when relative — or the supabase/database default). Go chdirs into the workdir, so it never prints a resolved absolute path. This follows the convention being applied to db pull's identical line in fix(cli): print Connecting line and relative paths in db pull output (CLI-1978) #5968 (CLI-1978).

Integration coverage: exact line text + stderr stream + single emission, ordering (after the declarative catalog warm, before the diff's exports) via export-call tracking in the existing seam mock, plus --yes and --no-cache scenarios. SIDE_EFFECTS.md documents the new stderr line.

Review findings deliberately left open (out of scope for CLI-1980)

  • generate (and pre-fix(cli): print Connecting line and relative paths in db pull output (CLI-1978) #5968 pull) still print the absolute dir for their ports of this same Go line (generate/generate.handler.ts:275, pull/pull.handler.ts:377). That is a separate pre-existing parity divergence: this PR's relative rendering is the Go-faithful one. pull's is being fixed in fix(cli): print Connecting line and relative paths in db pull output (CLI-1978) #5968; generate needs the same one-line declarativeDirRel treatment as a follow-up. Once all three converge, the emission is a candidate for a hoisted shared helper per the repo's hoist-before-you-duplicate rule.
  • Zero-files-generated edge: Go prints the written-to line before runDeclarativeSync's "did generation produce files?" check, so a pathological zero-file generation still prints the line before erroring. The TS handler keeps its pre-existing files-check-before-warm ordering, so that failure path errors without the line. Left as-is to avoid reordering pre-existing bootstrap verification in this PR.

Fixes CLI-1980
https://linear.app/supabase/issue/CLI-1980/db-schema-declarative-sync-bootstrap-omits-the-declarative-schema

…I-1980)

Go's sync bootstrap (no declarative files -> user agrees to generate)
delegates to declarative.Generate, which prints
'Declarative schema written to <dir>' to stderr after writing the files
and warming the catalog cache (declarative.go:133->138-155->156). The TS
bootstrap inlined the generate+write+warm but never emitted the line.

Emit it after the catalog warm, on both the interactive-accept and
--yes/SUPABASE_YES paths, and regardless of --no-cache — printing the
relative dir (Go's GetDeclarativeDir(): the config value verbatim or the
supabase/database default), never the resolved absolute path.
@Coly010

Coly010 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 37ff443fa6

ℹ️ 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".

@Coly010 Coly010 self-assigned this Jul 28, 2026
@Coly010
Coly010 marked this pull request as ready for review July 28, 2026 11:27
@Coly010
Coly010 requested a review from a team as a code owner July 28, 2026 11:27
@github-actions

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@37ff443fa6eb249c40ec401df4d287ab3d86591a

Preview package for commit 37ff443.

@kanadgupta kanadgupta left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small DRY suggestion that Claude suggested (and I verified) otherwise LGTM

CLI-1980 is fixed correctly: the sync bootstrap now prints Declarative schema written to <bold dir> to stderr after the write and the catalog warm, outside the --no-cache gate, on both the interactive-accept and --yes paths — matching Go's declarative.Generate (declarative.go:133→138-155→156) exactly, including the relative GetDeclarativeDir() rendering (the TS toml reader mirrors Go's supabase/-prefixing at config.go:982-984). The diff is proportionate — the ~105 test lines pin the exact text/stream/ordering and would fail without the fix; all 30 sync integration tests pass locally. One non-blocking inline suggestion: this adds a third literal copy of the parity-critical message string (generate and pull have the others), and a one-line shared formatter in the already-shared legacy-pgdelta.write.ts is separable from the deferred rel/abs convergence. The PR body's disclosed zero-files-generated ordering divergence is a reasonable out-of-scope call.

// dir today — pull's is moving to relative under CLI-1978; this rendering
// is the Go-faithful one.
yield* output.raw(
`Declarative schema written to ${legacyBold(declarativeDirRel)}\n`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DRY (non-blocking): this is now the third literal copy of the Declarative schema written to line (generate/generate.handler.ts:275, pull/pull.handler.ts:377). Go avoids the duplication structurally — sync's bootstrap delegates to the shared declarative.Generate, so the string lives in one place per path (declarative.go:156, pull.go:119).

The PR body's rationale for deferring a hoist (the three call sites don't yet print the same rendering) applies to unifying which dir is printed, but the format helper is separable from that convergence: a one-liner in legacy-pgdelta.write.ts (which all three handlers already import) would pin the parity-critical string in one place today, with each caller passing its current dir —

export const legacyDeclarativeSchemaWrittenLine = (dir: string) =>
  `Declarative schema written to ${legacyBold(dir)}\n`;

— and would turn the CLI-1978 pull fix and the generate follow-up into one-argument changes. Fine to batch with the generate follow-up if you prefer, but worth doing before a fourth copy appears.

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