migrate-db
Skill16 starsChanged 7 days agoMITView on GitHub
Thay đổi schema/dữ liệu cơ sở dữ liệu an toàn khi đang phục vụ — expand/contract thay cho sửa tại chỗ, DDL có lock_timeout, index CONCURRENTLY, ràng buộc NOT VALID rồi VALIDATE, backfill theo lô lũy đẳng, đường lùi đã thử, backup trước khi chạm dữ liệu thật. Dùng khi thêm/đổi/xoá bảng, cột, index, ràng buộc, đổi kiểu, chuyển dữ liệu, viết migration, khi người dùng nói "đổi schema", "migration", "đổi tên cột", hoặc gõ /migrate-db.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- jars-demo/jars-skillstheir own version, first seen Oct 25, 2026
- anshul-garg27/claude-enhancement-suitetheir own version, first seen Mar 10, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- anshul-garg27/claude-enhancement-suite★ 0same name
- jars-demo/jars-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- scripts/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- scripts/CLAUDE.mdCLAUDE.md
- tests/CLAUDE.mdCLAUDE.md
- adrSkill
- auditSkill
- autopilotSkill
- blueprintSkill
- completeSkill
- debugSkill
- factorySkill
- gateSkill
- handoverSkill
- incidentSkill
- migrate-dbSkill
- optimizeSkill
- researchSkill
- reviewSkill
- tddSkill
- ui-verifySkill
- upgradeSkill
- adrSkill
- auditSkill
- autopilotSkill
- blueprintSkill
- completeSkill
- debugSkill
- factorySkill
- gateSkill
- handoverSkill
- incidentSkill
- optimizeSkill
- researchSkill
- reviewSkill
- tddSkill
- ui-verifySkill
- upgradeSkill
The file
Files
/migrate-db — không khoá bảng, không mất dữ liệu, luôn lùi được
<FW> = .xtemplates/framework ở dự án đích, framework ở repo khung. Luật: <FW>/09-database/ — DB-MIG-001…012,
backup DB-BACKUP-008. Migration đã áp lên môi trường chung không sửa (DB-MIG-003); đổi migration đã áp = sửa cổng (LOOP-STOP-003).
1. Thiết kế (trước khi viết file)
- Ghi thay đổi đích và mọi chỗ đọc/ghi cột/bảng đó (
grepcode, job, báo cáo, view). - Chia expand/contract (
DB-MIG-008): (a) thêm cấu trúc mới, tương thích code cũ → (b) code ghi cả hai/đọc mới → (c) backfill → (d) chuyển đọc hoàn toàn → (e) xoá cũ ở bản phát hành sau. Mỗi bước một migration, mỗi bước deploy được độc lập. - Ước lượng kích thước bảng; bảng lớn → mọi bước phải không khoá lâu.
2. Viết migration
- File có phiên bản, áp bằng công cụ của dự án (
DB-MIG-001), lũy đẳng (DB-MIG-004:IF NOT EXISTS, kiểm trước khi chèn). - DDL trên bảng đang phục vụ:
SET lock_timeoutngắn +statement_timeout(DB-MIG-005); indexCREATE INDEX CONCURRENTLYngoài transaction (DB-MIG-006); FK/CHECKNOT VALIDrồiVALIDATE CONSTRAINTbước sau (DB-MIG-007). - Backfill theo lô có giới hạn + nghỉ, lũy đẳng, tiếp tục được khi đứt (
DB-MIG-010); không gom vào migration DDL. - Ghi đường lùi (
DB-MIG-009): migration down đã chạy thử, hoặc nhãn lùi bằng bước tiến kèm lý do. - Migration chạy tách khỏi khởi động app (
DB-MIG-012).
3. Kiểm
- Chạy toàn bộ migration trên CSDL sạch, rồi lên lần hai (lũy đẳng), rồi down → up (
DB-MIG-002). Test của code ở cả trạng thái trước và sau từng bước expand/contract. - Có dữ liệu mẫu cỡ thật: đo thời gian và khoá (
pg_locks/EXPLAIN) trên bản sao; vượt ngưỡng → chia nhỏ hơn. - Trước khi chạm dữ liệu production: backup/snapshot mới hoặc PITR đã kiểm (
DB-MIG-011,DB-BACKUP-008). Áp lên dữ liệu người dùng thật là điểm dừng (§Điểm dừng bắt buộc về hành động,LOOP-STOP-021):xt.py loop deferkèm kế hoạch, không tự chạy.
Báo cáo
Các bước expand/contract và PR tương ứng · lệnh kiểm + exit code (up, up lần 2, down→up) · thời gian/khoá đo được · đường lùi · việc chờ người.
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
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.

