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

migrate-create

它能做什么

这项技能创建一个带编号的新数据库迁移,包括一个正向文件和一个撤销文件。适合有条理地修改数据库结构的开发者。

适用场景

  • ✓当你需要为数据库添加表、列或索引时。
  • ✓当你希望为每项改动创建对应的撤销文件时。
  • ✓当你希望由系统为你选择下一个迁移编号时。

技能链接

https://github.com/ruvnet/ruflo/blob/main/plugins/ruflo-migrations/skills/migrate-create/SKILL.md

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“请创建一个迁移,为 tasks 表添加截止日期列,并附上它的撤销文件。”

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

工作原理

这项技能找到现有的最大编号并加一,然后根据名称开头(例如 create、add 或 drop)选择模板。它会写入正向和撤销的 SQL 文件,并记录该迁移。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Migrate Create

Generate a new database migration with sequential numbering and up/down SQL file pair.

When to use

When you need to create a new database migration for schema changes such as creating tables, adding columns, creating indexes, or modifying constraints.

Steps

  1. Determine next number -- use Glob to scan the migrations directory for existing migration files and find the highest number, then increment by 1 (zero-pad to 3 digits)
  2. Select template -- based on the <name>, choose the appropriate SQL template:
    • Names starting with create_ -> CREATE TABLE template
    • Names starting with add_ -> ALTER TABLE ADD COLUMN template
    • Names starting with drop_ -> DROP with safety checks
    • Names containing index -> CREATE INDEX template
    • Other -> generic migration template with placeholder comments
  3. Generate up migration -- write NNN_<name>.up.sql with the appropriate SQL using IF NOT EXISTS for idempotency
  4. Generate down migration -- write NNN_<name>.down.sql with the reverse operation using IF EXISTS
  5. Search past patterns -- call mcp__plugin_ruflo-core_ruflo__agentdb_pattern-search (ReasoningBank-routed; don't pass a namespace argument — pattern-* tools ignore it).
  6. Store metadata -- call mcp__plugin_ruflo-core_ruflo__memory_store --namespace migrations to record the migration with number, name, status (pending), and file paths. The memory_* tool family routes by namespace; agentdb_hierarchical-* does NOT (it routes by tier working|episodic|semantic), so use memory_* here. See ruflo-agentdb ADR-0001 §"Namespace convention".
  7. Report -- display: migration number, file paths created, template used, any similar past migrations found

CLI alternative

npx @claude-flow/cli@latest memory store --namespace migrations --key "migration-NNN_NAME" --value '{"number": NNN, "name": "NAME", "status": "pending"}'
常见问题

模板是如何选择的?

由名称开头决定。以 create、add 或 drop 开头的名称使用各自的模板,包含 index 的名称使用索引模板。

它会运行这个迁移吗?

描述中涵盖创建文件和记录元数据,并未说明会执行该迁移。

它会检查 SQL 吗?

单独的 migrate validate 技能会检查待执行迁移的安全性。

详情

作者的原始描述

Create a new sequentially numbered database migration with up/down SQL files

repo: ruvnet/ruflo

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能