用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill migration-zero-downtime命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | migration-zero-downtime |
| description | Zero-downtime migrations — expand/contract and rollback. |
Every migration must be forward-compatible with the current application version and backward-compatible with the previous one. At no point during a deploy may a running app instance encounter a schema it cannot handle.
Three separate deploys; never combine phases.
| Phase | What you deploy | What you do in the DB |
|---|---|---|
| 1 — Expand | Current app (unchanged) | Add new column/table (nullable or with default) |
| 2 — Dual-write | Updated app that writes to both old and new | Backfill existing rows; validate data in new shape |
| 3 — Contract | App that reads/writes only new column | Drop old column/table |
| Operation | Notes |
|---|---|
ADD COLUMN nullable | Must have no NOT NULL without a default |
ADD COLUMN with DEFAULT | Postgres 11+: instant metadata change, no rewrite |
CREATE TABLE | Always safe |
CREATE INDEX CONCURRENTLY | Does not block reads or writes (Postgres) |
ADD FOREIGN KEY NOT VALID | Skips full table scan; validate separately |
| Operation | Risk |
|---|---|
ADD COLUMN NOT NULL without default (pre-PG 11) | Full table rewrite, exclusive lock |
DROP COLUMN | Running app may still SELECT or INSERT it |
RENAME COLUMN | Breaks all app queries referencing old name |
CHANGE data type | May require full table rewrite; queries may fail |
DROP TABLE | Any app version referencing it fails immediately |
pt-online-schema-change (Percona Toolkit) or gh-ost (GitHub) for ALTER TABLE on live tables.pg_repack to reclaim space or reorder rows without an exclusive lock; use ALTER TABLE … SET DEFAULT + background backfill instead of a single large UPDATE.UPDATE touching millions of rows in one transaction.CREATE INDEX CONCURRENTLY; standard CREATE INDEX takes an exclusive lock.ALTER TABLE … ADD INDEX is online by default in InnoDB (MySQL 5.6+), but verify with ALGORITHM=INPLACE, LOCK=NONE.down migration.down in CI before merging — not just up.DROP COLUMN, DROP TABLE): take a snapshot or export the data before running the migration; store it somewhere recoverable for at least one release cycle.Gate new-schema app code behind a feature flag:
This decouples schema changes from behavior changes and allows instant rollback without a schema rollback.