cnfeat/top-pm-skills/database-migration-plan
Claude Code and agent skill by cnfeat/top-pm-skills
- community
Checking that the SKILL.md file is still in the repository.
Write a safe, zero-downtime database migration plan for a schema change. Use when asked to plan a database migration, design a zero-downtime schema change, document an expand/contract migration, produce a rollback procedure for a database change, or coordinate a database schema update with a deployment. Produces a structured migration plan covering migration objectives, backward compatibility analysis, expand/contract phase breakdown, exact SQL, rollback steps per phase, data validation queries, and a deployment runbook.
Install
npx vskill@latest install cnfeat/top-pm-skills/database-migration-planSKILL.md
The same SKILL.md was published earlier as mohitagw15856/pm-claude-skills/database-migration-plan.
Database Migration Plan Skill
Produce a complete, safe database migration plan for a schema change. A migration plan is not just the SQL — it is a coordinated sequence of steps that ensures the application stays available, data stays consistent, and every step can be rolled back independently.
The expand/contract pattern is the default approach: expand the schema to support both old and new states, migrate the application, then contract to remove the old state. Never combine schema changes and data backfills in a single migration that runs during deployment.
Required Inputs
Ask for these if not already provided:
- Current schema state — the DDL or description of the table(s) as they are now
- Target schema state — the DDL or description of what the table(s) should look like after migration
- Migration reason — why this change is being made (new feature, performance fix, normalization, compliance)
- Database engine — PostgreSQL, MySQL, SQLite, CockroachDB, etc.
- Estimated data volume — approximate number of rows in affected tables
- Deployment constraints — is any downtime allowed? What is the expected traffic level during migration? Are there multiple app instances running?
- Rollback window — how long after deploy can the team roll back before the migration becomes irreversible?
Output Format
Database Migration Plan: [Migration Name]
Service: [Name] | Team: [Team name] Author: [Name] | Reviewed by: [Name / DBA] Date: [Date] | Target deploy date: [Date] Database engine: [PostgreSQL X.X / MySQL X.X] Ticket: [JIRA-XXX]
1. Migration Overview
What is changing: [1–2 sentences: the specific schema change — e.g. "Adding a non-nullable organisation_id column to the users table and backfilling it from the accounts table."]
Why: [1–2 sentences: the business or technical reason driving the change.]
Migration type: [Additive only / Additive + backfill / Column rename / Column type change / Table restructure / Index change]
Zero-downtime: [Yes — using expand/contract / No — requires maintenance window — state duration]
Estimated migration duration:
- Expand phase: [~X minutes]
- Data backfill: [~X minutes/hours — based on X rows at Y rows/second]
- Contract phase: [~X minutes after app version deployed]
2. Backward Compatibility Analysis
Before writing a single line of SQL, assess whether each change is backward compatible with the currently deployed application code.
| Change | Backward compatible? | Risk | Notes | |
|---|---|---|---|---|
[e.g. Add nullable column org_id] | Yes | Low | Old app ignores new column | |
[e.g. Backfill org_id] | Yes | Medium | Old app unaffected; new app reads backfilled values | |
[e.g. Add NOT NULL constraint to org_id] | No | High | Old app that inserts without org_id will fail | |
[e.g. Drop old column account_id] | No | High | Old app that reads account_id will fail | |
[e.g. Add index on org_id] | Yes | Low | Additive; no breaking change | |
| [e.g. Rename column] | No | High | Never rename in one step; use expand/contract |
Summary: [e.g. "This migration requires the expand/contract pattern across 3 deployment phases because steps 3 and 4 are not backward compatible."]
3. Expand/Contract Phases
Phase Overview
Phase 1 — Expand Schema
Goal: Add the new column and structures without breaking the existing application. Deploy order: Run migration first, then (optionally) deploy app. Application state: Old app running; no app changes required yet.
Validation after Phase 1:
Rollback (Phase 1 only):
Phase 2 — Backfill Existing Data
Goal: Populate the new column for all existing rows before enforcing NOT NULL. When to run: After Phase 1 is live and stable. Can be run as a background job or a one-time script. Application state: Deploy app version that dual-writes to both old and new columns.
App code change required:
Backfill script — batch processing:
Monitoring during backfill:
Backfill completion validation:
Rollback (Phase 2 — app only):
- Deploy previous app version (single-write to old column)
org_idcolumn remains nullable; no data is lost- Backfilled values remain; harmless
Phase 3 — Enforce Constraints
Goal: Add NOT NULL constraint and remove dependency on the old column. Prerequisites: Phase 2 backfill must be 100% complete (zero rows with org_id IS NULL). Deploy order: Run migration, then deploy app version that reads only from org_id.
PostgreSQL — use NOT VALID + VALIDATE for large tables:
Validation after Phase 3:
Rollback (Phase 3):
Phase 4 — Contract (Remove Old Column)
Goal: Remove the old column once the app no longer references it. Prerequisites: Phase 3 fully deployed and stable for at least [X days/hours rollback window]. Warning: This phase is destructive — the old column's data is permanently deleted.
Pre-drop validation:
Rollback: Not straightforward — dropped column data cannot be recovered. Only proceed to Phase 4 after the rollback window has passed and the change is confirmed stable.
4. Data Validation Plan
Run these queries before and after the full migration to confirm data integrity.
Pre-migration baseline:
Post-backfill integrity check:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking参考skill/pm-claude-skills-main/pm-claude-skills-main/skills/database-migration-plan/SKILL.md
Popularity
- Repository stars
- 53
- Repository forks
- 5
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cnfeat/top-pm-skills/database-migration-plan)