Migrate

作者 get-convex6ca54f6e2e75无许可证6 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Safely migrate the schema + backfill data on a deployed Convex app with @convex-dev/migrations. TRIGGER when changing the schema on a live app, backfilling data, or after a schema-validation error from a change. SKIP a fresh local app.

AI 生成的概览

指导在已部署的 Convex 应用上安全迁移 schema 并使用 @convex-dev/migrations 回填数据。

功能
该技能提供在不停机、不破坏现有数据的前提下修改线上 Convex 应用 schema 的分步流程。内容包括:先将新字段设为可选以暂存 schema 变更、安装 @convex-dev/migrations、编写回填迁移以转换现有行、运行迁移,并在收紧校验器前核对行数。产出的是迁移方案与回填步骤,而非代码文件。
适用场景
适用于在已部署的 Convex 应用上修改 schema、回填现有数据,或变更后出现 schema 校验错误时。不适用于全新的本地应用。
运行要求
需要一个已部署的 Convex 应用以及 @convex-dev/migrations 包。仅为说明性指令,不包含脚本。

Migrate the schema / data on a live app

Change a deployed schema without breaking existing data: stage the schema change, install @convex-dev/migrations, write a backfill that makes old rows valid, run it, and verify before tightening the validator.

Steps

  1. Make the new field optional first (so deploy doesn't reject existing rows).
  2. Install @convex-dev/migrations; write a migration that backfills/transforms existing rows.
  3. Run the migration; verify all rows are valid.
  4. Tighten the validator (make the field required) once the backfill is complete.

Rules

  • Never tighten a validator before the backfill completes — it rejects existing rows and breaks the live app.
  • Add new fields as optional first, migrate, then require.
  • Verify row counts before and after.

来源与署名

来源:get-convex/convex-backend-skill位于skills/migrate提交6ca54f6

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架