跳到正文
Skillpedia
API 与服务器(后端)9.5k · #12249

convex-migrate

它能做什么

这个技能会更新已有真实数据的 Convex 应用的数据库结构。适合需要在不破坏线上应用的前提下修改数据表的开发者。

适用场景

  • ✓当你想为已有记录的数据表添加必填字段时。
  • ✓当你需要在线上应用中重命名、修改或拆分字段时。
  • ✓当你需要在收紧规则之前,为旧记录补齐缺失的值时。

技能链接

https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-migrate/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/openclaw/clawhub/blob/main/.agents/skills/convex-migrate/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请为我的 users 表添加一个必填的 email 字段,同时不影响我已有的用户。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会先把新字段设为可选,安装迁移库,编写一个为旧记录填充数据的步骤并运行,检查记录数量,然后才将该字段设为必填。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

<!-- GENERATED from convex-agents content/capabilities/migrate.json — do not edit by hand. -->

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.

Workflow

  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.
常见问题

为什么不直接把字段设为必填?

现有记录会不符合新规则,从而导致线上应用出错。

智能体怎么知道迁移成功了?

它会比较迁移前后的记录数量,并在收紧规则之前检查所有记录是否有效。

它使用哪个库?

它使用 Convex 迁移库,该库会分批运行变更,同时应用保持正常运行。

详情

作者的原始描述

Migrate schema + backfill data on a deployed Convex app using @convex-dev/migrations.

repo: openclaw/clawhub

热度

GitHub 星标
9.5k
排名
#12249
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能