home / skills / microck / ordinary-claude-skills / data-migration

data-migration skill

/skills_all/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-migration

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1.7 KB
---
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)

Overview

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.

How this skill works

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.

When to use it

  • When changing database schemas in production and needing a safe rollout
  • When transforming or normalizing existing data across tables or systems
  • When migrating data between database engines or cloud providers
  • When implementing versioned migrations and CI/CD migration pipelines
  • When planning zero-downtime deployments or backfill operations

Best practices

  • Use small, reversible migration steps: add before remove and backfill before switching reads
  • Instrument migrations with verification checks and automated tests in staging
  • Implement dual-write and/or read mirroring to avoid data loss during transition
  • Prepare explicit rollback procedures and test them in a non-production environment
  • Monitor performance and data integrity metrics throughout the rollout

Example use cases

  • Add a new email column, dual-write for a period, backfill historical values, then switch reads and remove the old column
  • Migrate user data from a legacy relational database to a modern cloud database with schema transformations and validation
  • Implement versioned migrations tied to application releases, with automated preflight checks in CI
  • Perform a zero-downtime refactor by creating parallel schema paths and gradually shifting traffic
  • Backfill derived fields needed by new features while preserving old behavior until validation passes

FAQ

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.