agentleFS
liushikuan63liushikuan63/Qoder-Optimization/skills/local-db-migrations/SKILL.md

local-db-migrations

Skill2 starsChanged 11 days agoMITView on GitHub

补充数据库 schema 与数据迁移的兼容、锁、回填和恢复验证;用于写迁移或迁移评审,不用于普通查询修改。

The file

Files
SKILL.md

本地数据库迁移

先确认实际数据库引擎与版本、迁移工具、已应用版本、表量级和并发访问。从现有迁移历史与部署顺序定位修改范围;缺少数据库版本、数据规模等关键信息时,先完成静态方案与待验证项,不宣称零停机。

迁移设计

  • 已执行的版本化迁移可能受校验和管理,不改写它来修复历史;依据项目工具增加新的修正迁移。未应用的本次文件可在确认归属后修订。
  • 列重命名、拆分或类型变化采用适合项目的扩展、兼容读写、分批回填、核验、切换、最后收缩。旧客户端或旧服务仍在使用时,不立即删掉其依赖字段。
  • 区分结构变化与长时间回填。回填使用稳定键、有界批次和恢复位置,并验证重跑是否会覆盖新写入或重复生成结果;避免在一个巨大事务内处理全表。
  • 新增 nullable 列仍可能获取元数据/表锁,不能称为“无锁”。DEFAULT、NOT NULL、索引和 DDL 事务行为依引擎及版本判断。PostgreSQL 的并发建索引有事务限制与失败残留;MySQL 的在线 DDL 选项不能直接套 PostgreSQL。执行前查目标版本官方文档。
  • 恢复计划区分应用回退、schema 恢复和数据恢复。删除列或有损转换不能靠 DOWN 文件保证恢复;需要可验证的备份/恢复或前向修复方案。遵循项目迁移工具能力,不强制所有工具都有 DOWN。

验证与执行范围

在有授权的隔离数据库或 fixture 上验证迁移链、约束、旧/新代码兼容、回填恢复与真实可逆性;涉及大表性能时需有相应数据规模及锁等待证据。没有服务或代表性数据时,只交付静态检查和准确缺口。准备迁移文件不代表批准执行生产变更;生产执行仍遵守当前授权。

参考锁语义:PostgreSQL 官方说明。该 current 页面不代表项目锁定版本。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.