Skip to content

cli: don't create tables or indexes on the deployment during codegen - #203

Open
CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/codegen-no-deploy-199
Open

CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/codegen-no-deploy-199

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

Fixes #199.

Root cause

npx convex codegen runs through startComponentsPushAndCodegen (src/cli/lib/components.ts), which builds a startPushRequest and calls startPush -> POST /api/deploy2/start_push to get the backend's evaluated schema for the generated bindings. The request carried dryRun: options.dryRun, and for a normal npx convex codegen invocation that is false, so the backend provisioned the schema as part of start_push and created the tables and indexes on the deployment. The CLI only ever needed the evaluated analysis; it never finalizes a push in the codegen path (no finishPush). The --help text saying codegen "doesn't modify the code running on the deployment" was therefore wrong in practice.

The change (src/cli/lib/components.ts)

  • The start_push request is now marked as a dry run whenever the push is a codegen run (dryRun: options.dryRun || options.codegen, extracted into the exported isDryRunStartPush() helper). dryRun is the protocol's established don't-mutate signal, the same one npx convex deploy --dry-run relies on; the evaluated schema the bindings need is exactly what a dry-run push returns.
  • The "Uploading functions to Convex..." spinner is codegen-aware now ("Analyzing functions for codegen...") since codegen no longer uploads anything.
  • Added src/cli/lib/components.codegen.test.ts with a truth-table test pinning the policy: normal deploy is not a dry run, deploy --dry-run is, and codegen always is.

Test evidence

  • npx vitest run: 6/6 passing (5 existing aiFiles tests + the new codegen test).
  • tsc --noEmit --emitDeclarationOnly false: clean, exit 0.

Honest limits

The table/index creation happens server-side on start_push; I could not run codegen against a live deployment from this sandbox, so the backend's dry-run behavior is taken from the protocol's documented contract (deploy --dry-run previews without applying). Happy to adjust if the team prefers a dedicated flag over reusing dryRun.

`npx convex codegen` calls start_push to get the backend's evaluated
schema for the generated bindings, but the request was not marked as a
dry run, so the backend provisioned the schema and created tables and
indexes on the deployment - contradicting the --help text that says
codegen doesn't modify the code running on the deployment.

Mark the start_push request as a dry run for codegen runs. `dryRun`
is the protocol's established don't-mutate signal (the same one
`npx convex deploy --dry-run` relies on). The spinner text is also
codegen-aware now instead of claiming to upload functions.

Fixes convex#199

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
@CloudCorpRecords
CloudCorpRecords force-pushed the fix/codegen-no-deploy-199 branch from 9f4d50c to 6fd83b8 Compare October 20, 2026 21:21
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.

codegen creates tables and indexes on the deployment, though --help says it does not modify it

1 participant