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 從公開儲存庫中收錄這些內容。

檢舉或申請下架