Rehearse a schema change on a preview before prod
A schema push on Convex validates every existing document against the new schema and FAILS the push if any row doesn't conform — a real data-conformance gate. The safe way to use that gate is to let it fail on a rehearsal copy, not on prod. This capability turns a preview deployment into that copy: seed it with a prod snapshot, push the new schema + run the backfill there, watch the gate, and only promote once it's green. It composes deploy-guard (target classification), migrate (the optional-then-tighten pattern), and @convex-dev/migrations (the batched, resumable backfill).
Workflow
PRECONDITION: preview deployments need a Preview Deploy Key (dashboard → Project Settings → Deploy Keys → Preview) exported as
CONVEX_DEPLOY_KEY
before any
--preview-create
/
--preview-name
deploy — a plain
npx convex login
session cannot create previews, and this is a paid-tier feature. If no preview key is available, fall back to rehearsing on the personal dev deployment seeded with the snapshot, and say so.
GUARD: deploy-guard — classify + announce the SOURCE (prod, being read) and the eventual TARGET (prod, being changed); get the fresh explicit yes for the prod promote up front and confirm the plan.
SNAPSHOT the source data read-only:
npx convex export --path snapshot.zip
(from the deployment holding the real data; add
--include-file-storage
only if the migration touches files). This is a read; it changes nothing.
CREATE the preview FROM THE PRE-CHANGE CODE — do this BEFORE editing schema.ts, so the preview starts on the schema the snapshot data already conforms to:
npx convex deploy --preview-create migrate-
convex-migrate-rehearse
安装
npx skills add https://github.com/get-convex/agent-skills --skill convex-migrate-rehearse