home / skills / microck / ordinary-claude-skills / data-migration
This skill plans and executes safe database migrations with rollback strategies and data integrity validation, enabling zero downtime transitions.
npx playbooks add skill microck/ordinary-claude-skills --skill data-migrationReview the files below or copy the command above to add this skill to your agents.
---
name: data-migration
description: Plan and execute database migrations, data transformations, and system migrations safely with rollback strategies and data integrity validation. Use when migrating databases, transforming data schemas, moving between database systems, implementing versioned migrations, handling data transformations, ensuring data integrity, or planning zero-downtime migrations.
---
# Data Migration - Safe Schema Changes
## When to use this skill
- Migrating database schemas and structures
- Transforming data between formats
- Moving data between database systems
- Implementing versioned database migrations
- Handling data transformations during migrations
- Ensuring data integrity and validation
- Planning zero-downtime migrations
- Rolling back failed migrations safely
- Migrating from legacy systems
- Implementing data backfill strategies
- Testing migrations in staging environments
- Creating migration rollback procedures
## When to use this skill
- Migrating data between schemas, zero-downtime deployments.
- When working on related tasks or features
- During development that requires this expertise
**Use when**: Migrating data between schemas, zero-downtime deployments.
## Process
1. Add new column
2. Dual-write to old & new
3. Backfill historical data
4. Switch reads to new column
5. Remove old column
## Example
\`\`\`sql
-- Step 1: Add column
ALTER TABLE users ADD COLUMN email_new VARCHAR(255);
-- Step 2: Backfill
UPDATE users SET email_new = email WHERE email_new IS NULL;
-- Step 3: Swap
ALTER TABLE users DROP COLUMN email;
ALTER TABLE users RENAME COLUMN email_new TO email;
\`\`\`
## Resources
- [Database Migrations](https://www.prisma.io/docs/concepts/components/prisma-migrate)
This skill helps plan and execute safe database and system migrations with a focus on data integrity, rollback strategies, and minimal downtime. It provides practical migration patterns, step-by-step procedures for schema changes, and validation checks to reduce risk. The skill is implemented in Python and supports versioned migrations, data transformations, and cross-database moves.
The skill inspects current schema and data shape, generates a migration plan, and can produce migration scripts for staged deployment. It recommends dual-write or parallel-schema strategies, backfill procedures, and read-switch steps to enable zero-downtime changes. It also includes validation routines and predefined rollback steps to revert changes safely when issues are detected.
How do I test rollbacks safely?
Run the rollback procedure in a staging environment with an anonymized snapshot of production data and verify integrity checks and application compatibility before using it in production.
When should I use dual-write vs. read-switch?
Use dual-write when you need live writes to populate a new schema while maintaining the old one; use read-switch after backfill and verification to migrate traffic with minimal disruption.