一键导入
migration-safety
Safe migration patterns for databases, APIs, libraries, and data transformations with zero-downtime techniques and mandatory rollback planning.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Safe migration patterns for databases, APIs, libraries, and data transformations with zero-downtime techniques and mandatory rollback planning.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Behavioral rules that make AI coding agents more reliable — verification, self-correction, and scope discipline.
Debugging guidance and structured report template for thorough bug investigation, evidence gathering, and root cause documentation.
Cold-audit a completed delivery — verify the spec was actually delivered, challenge performative claims, and produce a what-landed report.
Guidelines for generating self-contained HTML mockups that look professional and are easy to iterate on.
Shared implementation guidance for making minimal, correct, maintainable code changes that fit existing systems.
The doctrine for `/roadmap-review` — interactive triage of roadmap-shape drift, walked one item at a time, with paste-ready resolution phrasing for the active sizing lens.
| name | migration-safety |
| description | Safe migration patterns for databases, APIs, libraries, and data transformations with zero-downtime techniques and mandatory rollback planning. |
| compatibility | opencode |
| metadata | {"audience":"migration-engineer, platform-delivery-lead","purpose":"migration-guidance"} |
Provide actionable guidance for planning and executing migrations safely. Every migration — schema, data, API, or library — must have a tested rollback path, a monitoring plan, and a strategy that avoids downtime.
Load this skill when planning or executing any migration: database schema changes, data transformations, API version transitions, or library upgrades. The migration-engineer and platform-delivery-lead should load this before writing or reviewing a migration spec.
Every migration is a contract with production. You are changing something that running systems depend on. The cost of a failed migration is not "we fix it tomorrow" — it's data loss, broken clients, or extended downtime. Plan accordingly.
The safest general-purpose pattern. Three phases:
Never collapse these into one step. The expand phase is your safety net — if anything goes wrong during migration, you still have the old structure intact.
Run two complete environments in parallel. Route traffic to the new environment after verification. Keep the old environment warm for instant rollback.
Use blue-green when:
Gate new behavior behind a flag. Roll out gradually — 1%, 10%, 50%, 100%. Monitor error rates at each stage.
Use feature flags when:
Every schema migration must be backwards-compatible with the currently deployed application code. The deployment sequence is: deploy schema change, then deploy application code. If the schema change breaks existing code, you have a window of failure between the two deployments.
Safe operations:
CREATE INDEX CONCURRENTLY on PostgreSQL to avoid locks)VARCHAR(50) to VARCHAR(100))Unsafe operations (require expand-contract):
Every migration script must have a corresponding rollback script. Test the rollback on a copy of production data before running the forward migration.
Long-running migrations on large tables can acquire locks that block reads/writes. Mitigate this:
pt-online-schema-change for MySQL, pg_repack for PostgreSQL) for large table alterationsNever transform all rows in a single transaction. Process in batches:
Every data transformation must be safe to run multiple times. If the job crashes at batch 5,000 and restarts from batch 4,900, the overlapping rows must not be corrupted.
Design for idempotency:
INSERT ... ON CONFLICT DO UPDATE instead of blind insertsUPDATE ... WHERE status != 'migrated'Before, during, and after:
When migrating an API version:
/v2/users alongside /v1/users)Deprecation, Sunset) to v1 responses during the transitionNever skip major versions. If you're on v2 and need v5, upgrade v2→v3→v4→v5 sequentially. Each step should be a separate commit with passing tests.
When a library's API changes significantly between versions, introduce an adapter layer:
For breaking changes in function signatures or behavior:
@deprecated or equivalent so they get cleaned upEvery migration must have a documented rollback plan. This is non-negotiable.
The rollback plan must answer:
Test the rollback before running the migration. If you can't test it, you're not ready to migrate.
Abort the migration if:
Aborting is not failure — it's professionalism. A migration that's aborted and retried after investigation is far better than one that's pushed through and causes an incident.