Skip to content

feat(cli): add --exit-code to declarative sync (CLI-3325) - #7906

Open
7ttp wants to merge 5 commits into
developfrom
7ttp/cli-3325-db-schema-declarative-sync-a-check-mode-that
Open

7ttp wants to merge 5 commits into
developfrom
7ttp/cli-3325-db-schema-declarative-sync-a-check-mode-that

Conversation

@7ttp

@7ttp 7ttp commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

TL;DR

adds --exit-code to db schema declarative sync so CI can fail on schema changes without writing a migration.

whats introduced?

supabase db schema declarative sync --exit-code plans as usual and prints the SQL, then exits 2 when the schema files and migrations differ and 0 when they match. errors keep exiting 1, the same split as config diff --exit-code.

with --output-format json it also prints changed, sql and destructive on stdout, so CI can read the result without parsing stderr.

with the flag sync writes no migration, applies nothing and never prompts. a missing schema or a compatibility repair exits 1 instead of offering to generate, stage or reset, even with --yes.

the flag is off by default, so runs without it behave exactly as before.

why?

sync exited 0 both when nothing changed and when it wrote a new migration, and --output-format json printed nothing either way, so a CI check had to grep the No schema changes found line and still got a new migration file in its checkout on every change.

ref

@7ttp 7ttp self-assigned this Dec 1, 2026
@7ttp
7ttp requested a review from a team as a code owner December 1, 2026 12:48
@7ttp
7ttp requested a review from kanadgupta December 1, 2026 12:48
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

CLI benchmark (Lightweight Commands): no changes found

Commit c48ed71 against develop at d6d2b21 · 10 runs each · report only, never blocks merging

Command Workload Before After Change
supabase --version version 255 ms 236 ms no real change (-7%, within normal variation)
supabase --help help 269 ms 238 ms no real change (-11%, within normal variation)
supabase init init 208 ms 213 ms no real change
supabase migration new bench migration-new 224 ms 218 ms no real change
supabase config convert config-convert 222 ms 214 ms no real change
supabase config validate config-validate 261 ms 248 ms no real change
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 285 ms 296 ms no real change
supabase projects list projects-list 272 ms 261 ms no real change
supabase functions list --project-ref replayfixtureprojref functions-list 256 ms 252 ms no real change

API calls: unchanged for all 9 commands.

Binary size: 135.7 MB, unchanged.

Details: timing ranges, API calls per command, slowest phases

Timing ranges

Command Workload Before range After range Change Verdict
supabase --version version 199-410 ms 201-393 ms -19 ms (-7%) within noise
supabase --help help 230-471 ms 211-391 ms -30 ms (-11%) within noise
supabase init init 196-246 ms 188-254 ms +5 ms (+2%) within noise
supabase migration new bench migration-new 202-231 ms 208-242 ms -6 ms (-3%) within noise
supabase config convert config-convert 206-257 ms 193-248 ms -8 ms (-4%) within noise
supabase config validate config-validate 226-468 ms 215-339 ms -13 ms (-5%) within noise
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 246-332 ms 268-340 ms +11 ms (+4%) within noise
supabase projects list projects-list 254-293 ms 241-301 ms -11 ms (-4%) within noise
supabase functions list --project-ref replayfixtureprojref functions-list 232-294 ms 234-303 ms -3 ms (-1%) within noise

API calls per command

Command Workload Before After Endpoint changes
supabase --version version 0 0
supabase --help help 0 0
supabase init init 0 0
supabase migration new bench migration-new 0 0
supabase config convert config-convert 0 0
supabase config validate config-validate 0 0
supabase gen types --lang typescript --project-id replayfixtureprojref gen-types 2 2
supabase projects list projects-list 1 1
supabase functions list --project-ref replayfixtureprojref functions-list 2 2

Slowest phases

No command moved beyond noise, so there are no phase deltas.

Workflow run

Comment /bench to run the lightweight benchmark (this comment) again on the latest commit, or /bench full to also run the integration-heavy benchmark, which posts in its own comment.

@github-actions github-actions Bot 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.

🤖 AI Review

CLI reference prose guidance: snapshot supabase/supabase@cebd7a5 supplied to reviewers (advisory, not a style pass).

Both independent reviews were available. Code inspection confirmed five distinct findings. The destructive-change hint can apply destructive SQL during a rerun intended to write a migration for review. Check mode silently ignores explicit apply and file options, and the tests omit the --exit-code --apply combination. The remaining findings concern the check-mode SQL heading and the new flag help. The reference overlay still describes the default workflow.

Findings

Severity Location Category Sources Claim
🟡 MINOR apps/cli/src/commands/db/schema/declarative/sync/sync.handler.ts:471 error-handling codex Following the destructive-change hint to write a migration for review can immediately apply destructive SQL to the local database if the rerun keeps --apply or --yes.
🟡 MINOR apps/cli/src/commands/db/schema/declarative/sync/sync.handler.ts:475 flag-validation claude --exit-code accepts and silently overrides --apply, --name, and --file, so a caller can request a migration file or local apply and receive only a check result.
🟡 MINOR apps/cli/src/commands/db/schema/declarative/sync/sync.integration.test.ts:1458 test-coverage codex The check-mode regression test leaves the precedence of --exit-code over explicit --apply untested.
⚪ NIT apps/cli/src/commands/db/schema/declarative/sync/sync.handler.ts:476 ux claude Check-mode output labels the preview Generated migration SQL: and leaves users to infer whether a migration file was created.
⚪ NIT apps/cli/src/commands/db/schema/declarative/sync/sync.command.ts:62 docs-style codex The new --exit-code help puts the error status in parentheses and omits the Oxford comma.

Stats

Claude findings: 2 · Codex findings: 3 · Confirmed: 5 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5-5 + gpt-6.2-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

@jgoux jgoux 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.

The exit-code contract works: 0 when nothing changed, 1 on errors, 2 when changes are found. Every prompt, bootstrap, repair, write, and apply path is gated before the early return, and --fail-on-destructive still takes precedence. One gap against the linked issue and one design note are inline.

@blacksmith-sh

This comment has been minimized.

@7ttp
7ttp requested a review from jgoux December 2, 2026 12:11

This branch has not been deployed

No deployments
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.

db schema declarative sync: a --check mode that exits non-zero when there is a diff

2 participants