返回顶部
d

db-migrate

Deep database migration workflow—expand/contract, backward-compatible deploys, backfills, locking risks, and verification. Use when changing production schemas safely with zero or low downtime.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
97
下载量
0
收藏
概述
安装方式
版本历史

db-migrate

# DB Migrations Production schema changes fail when old and new code disagree during rollout. Prefer **expand/contract**: add compatible changes first, remove old shapes later. ## When to Offer This Workflow **Trigger conditions:** - ALTER TABLE in production; large table rewrites - Blue/green deploys coupled to schema state - Need zero-downtime or low-downtime migrations **Initial offer:** Use **six stages**: (1) classify change, (2) expand phase, (3) backfill & dual-write, (4) flip reads/writes, (5) contract phase, (6) verify & rollback). Confirm database engine (PostgreSQL, MySQL, etc.). --- ## Stage 1: Classify Change **Goal:** Additive vs destructive; lock risk (full table rewrite vs instant metadata change). **Exit condition:** Migration labeled as expand or contract with risk notes. --- ## Stage 2: Expand Phase **Goal:** Add nullable columns or new tables without breaking currently deployed code. ### Practices - Avoid DEFAULT clauses that lock large tables badly on some engines (use phased backfill instead) --- ## Stage 3: Backfill & Dual-Write **Goal:** Throttled batch backfill; dual-write old and new representations during transition when needed. --- ## Stage 4: Flip Reads/Writes **Goal:** Deploy code that reads new columns only after backfill completes; use feature flags for staged rollout. --- ## Stage 5: Contract Phase **Goal:** Drop old columns only after no code references them (search repo, logs, feature usage). --- ## Stage 6: Verify & Rollback **Goal:** Monitor errors, slow queries, replication lag; rollback = redeploy previous app version + avoid destructive steps until stable. --- ## Final Review Checklist - [ ] Change classified; expand/contract path clear - [ ] Additive migrations before dependent code - [ ] Backfill throttled and verified - [ ] Read/write cutover sequenced with flags - [ ] Contract only after references gone - [ ] Monitoring and rollback tested ## Tips for Effective Guidance - Long transactions on migrations can cause outages—chunk work. - Use online schema tools (pt-online-schema-change, etc.) when appropriate. ## Handling Deviations - SQLite/embedded engines have different locking—validate per engine.

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 db-migrate-1775984101 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 db-migrate-1775984101 技能

通过命令行安装

skillhub install db-migrate-1775984101

下载 Zip 包

⬇ 下载 db-migrate v1.0.0

文件大小: 1.77 KB | 发布时间: 2026-4-13 09:59

v1.0.0 最新 2026-4-13 09:59
db-migrate v1.0.0 – Initial Release

- Introduces a comprehensive workflow for safe, low-downtime database schema migrations using the expand/contract pattern.
- Details six migration stages: classify change, expand, backfill & dual-write, flip reads/writes, contract, and verify & rollback.
- Provides practical advice on backfills, locking risk mitigation, and staged rollouts.
- Includes a final review checklist and tips specific to production use and different database engines.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部