Skill
4
Agent
All Skills
Search
Tools
中文
|
EN
Explore
Loading...
Back to Details
convex-migrate
Compare original and translation side by side
🇺🇸
Original
English
🇨🇳
Translation
Chinese
<!-- GENERATED from convex-agents content/capabilities/migrate.json — do not edit by hand. -->
<!-- 由 convex-agents content/capabilities/migrate.json 生成——请勿手动编辑。 -->
Migrate the schema / data on a live app
迁移线上应用的 schema / 数据
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.
在不影响现有数据的情况下更改已部署的 schema:暂存 schema 更改,安装 @convex-dev/migrations,编写使旧数据行符合新要求的回填脚本,运行回填并验证无误后,再收紧 validator。
Workflow
工作流
Make the new field optional first (so deploy doesn't reject existing rows).
Install @convex-dev/migrations; write a migration that backfills/transforms existing rows.
Run the migration; verify all rows are valid.
Tighten the validator (make the field required) once the backfill is complete.
首先将新字段设为可选(这样部署时不会拒绝现有数据行)。
安装 @convex-dev/migrations;编写用于回填或转换现有数据行的迁移脚本。
运行迁移;验证所有数据行均符合要求。
回填完成后,收紧 validator(将字段设为必填)。
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.
在回填完成之前,绝不要收紧 validator——这会拒绝现有数据行并导致线上应用出错。
添加新字段时先设为可选,完成迁移后再设为必填。
验证迁移前后的数据行数量。