Data Migration Specialist
Plan and execute large-scale data migrations with zero-downtime strategies, comprehensive validation, and reliable rollback plans.
Activation Triggers
Activate on: "data migration", "database migration", "zero-downtime migration", "dual-write", "backfill", "cutover", "data validation", "schema migration", "platform migration", "cloud migration"
NOT for: Streaming schema evolution → schema-evolution-manager | API backward compatibility → api-versioning-backward-compatibility | Warehouse optimization → data-warehouse-optimizer
Quick Start
- Audit source data — profile row counts, data types, nulls, constraints, and edge cases
- Choose strategy — big bang (downtime), dual-write (zero-downtime), CDC-based (continuous sync)
- Build validation framework — row counts, checksums, spot checks, and business rule assertions
- Run rehearsal — execute full migration on staging with production-scale data
- Plan rollback — define rollback triggers, procedure, and maximum acceptable rollback window
Core Capabilities
| Domain |
Technologies |
| Strategies |
Dual-write, CDC-based, big bang, strangler fig |
| CDC Tools |
Debezium, AWS DMS, GCP Datastream, pglogical |
| Validation |
Great Expectations, custom checksums, row-count reconciliation |
| Schema |
Flyway, Liquibase, Prisma Migrate, Alembic |
| Orchestration |
Airflow, Temporal, custom migration scripts |
Architecture Patterns
Zero-Downtime Migration (Dual-Write)
Phase 1: Dual-Write (days/weeks)
──────────────────────────────────
App writes → Old DB (primary)
→ New DB (shadow, async)
Reads from: Old DB only
Phase 2: Shadow Read Validation
──────────────────────────────────
App writes → Old DB + New DB
Reads from: Old DB (primary)
New DB (shadow, compare results)
Phase 3: Cutover
──────────────────────────────────
App writes → New DB (primary)
→ Old DB (shadow, for rollback)
Reads from: New DB
Phase 4: Cleanup
──────────────────────────────────
App writes → New DB only
Remove old DB writes
Decommission old DB (after rollback window expires)
Validation Framework
class MigrationValidator:
"""Run after each migration phase to verify data integrity."""
def validate_row_counts(self):
"""Source and target row counts must match within tolerance."""
for table in self.tables:
source = self.source_db.count(table)
target = self.target_db.count(table)
tolerance = 0.001 # 0.1% tolerance for in-flight writes
assert abs(source - target) / source < tolerance, \
f"{table}: source={source}, target={target}"
def validate_checksums(self):
"""Hash comparison on sampled rows."""
for table in self.tables:
sample_ids = self.source_db.sample_ids(table, n=10000)
for batch in chunked(sample_ids, 1000):
source_hash = self.source_db.hash_rows(table, batch)
target_hash = self.target_db.hash_rows(table, batch)
assert source_hash == target_hash, \
f"{table}: checksum mismatch in batch"
def validate_business_rules(self):
"""Domain-specific invariants."""
# Example: total revenue must match
source_rev = self.source_db.query("SELECT SUM(amount) FROM orders")
target_rev = self.target_db.query("SELECT SUM(amount) FROM orders")
assert source_rev == target_rev, "Revenue mismatch!"
def validate_constraints(self):
"""All FKs, unique constraints, and NOT NULLs hold on target."""
violations = self.target_db.check_constraints()
assert len(violations) == 0, f"Constraint violations: {violations}"
Rollback Decision Tree
Migration issue detected?
│
├─ Data loss or corruption? → IMMEDIATE ROLLBACK
│ Switch reads/writes back to old DB
│ Replay writes from new DB → old DB (if needed)
│
├─ Performance regression? → EVALUATE
│ ├─ < 2x slower → optimize, do not rollback
│ └─ > 2x slower → rollback, investigate
│
└─ Minor data discrepancy? → FIX FORWARD
Run reconciliation job to sync
Do NOT rollback for fixable issues
Rollback window: keep old DB live for 7-14 days post-cutover
Anti-Patterns
- No rehearsal — always run the full migration on staging with production-scale data before the real cutover
- Validation after cutover only — validate continuously during dual-write phase, not just at the end
- No rollback plan — every migration needs a documented rollback procedure with defined triggers
- Big bang for large datasets — migrating 1TB+ in one shot risks extended downtime; use CDC or phased approach
- Ignoring edge cases — NULLs, empty strings, Unicode, timezone differences, and precision loss cause subtle data corruption
Quality Checklist
1---
2license: Apache-2.0
3name: data-migration-specialist
4description: "Large-scale data migrations with validation, rollback, and zero-downtime strategies. Activate on: data migration, database migration, zero-downtime migration, dual-write, backfill, cutover, data validation, schema migration. NOT for: schema evolution in streams (use schema-evolution-manager), API versioning (use api-versioning-backward-compatibility)."
5allowed-tools: Read,Write,Edit,Bash(npm:*,npx:*,python:*,psql:*,docker:*)
6category: Data & Analytics
7tags:
8 - data-migration
9 - zero-downtime
10 - validation
11 - rollback
12 - cutover
13pairs-with:
14 - skill: database-connection-pool-manager
15 reason: Migrations impact connection pooling during cutover
16 - skill: data-quality-guardian
17 reason: Post-migration validation requires quality checks
18 - skill: schema-evolution-manager
19 reason: Schema changes accompany data migrations
20metadata:
21 source: https://skillmd.com/skills/curiositech/data-migration-specialist
22---
23
24# Data Migration Specialist
25
26Plan and execute large-scale data migrations with zero-downtime strategies, comprehensive validation, and reliable rollback plans.
27
28## Activation Triggers
29
30**Activate on:** "data migration", "database migration", "zero-downtime migration", "dual-write", "backfill", "cutover", "data validation", "schema migration", "platform migration", "cloud migration"
31
32**NOT for:** Streaming schema evolution → `schema-evolution-manager` | API backward compatibility → `api-versioning-backward-compatibility` | Warehouse optimization → `data-warehouse-optimizer`
33
34## Quick Start
35
361. **Audit source data** — profile row counts, data types, nulls, constraints, and edge cases
372. **Choose strategy** — big bang (downtime), dual-write (zero-downtime), CDC-based (continuous sync)
383. **Build validation framework** — row counts, checksums, spot checks, and business rule assertions
394. **Run rehearsal** — execute full migration on staging with production-scale data
405. **Plan rollback** — define rollback triggers, procedure, and maximum acceptable rollback window
41
42## Core Capabilities
43
44| Domain | Technologies |
45|--------|-------------|
46| **Strategies** | Dual-write, CDC-based, big bang, strangler fig |
47| **CDC Tools** | Debezium, AWS DMS, GCP Datastream, pglogical |
48| **Validation** | Great Expectations, custom checksums, row-count reconciliation |
49| **Schema** | Flyway, Liquibase, Prisma Migrate, Alembic |
50| **Orchestration** | Airflow, Temporal, custom migration scripts |
51
52## Architecture Patterns
53
54### Zero-Downtime Migration (Dual-Write)
55
56```
57Phase 1: Dual-Write (days/weeks)
58──────────────────────────────────
59App writes → Old DB (primary)
60 → New DB (shadow, async)
61Reads from: Old DB only
62
63Phase 2: Shadow Read Validation
64──────────────────────────────────
65App writes → Old DB + New DB
66Reads from: Old DB (primary)
67 New DB (shadow, compare results)
68
69Phase 3: Cutover
70──────────────────────────────────
71App writes → New DB (primary)
72 → Old DB (shadow, for rollback)
73Reads from: New DB
74
75Phase 4: Cleanup
76──────────────────────────────────
77App writes → New DB only
78Remove old DB writes
79Decommission old DB (after rollback window expires)
80```
81
82### Validation Framework
83
84```python
85class MigrationValidator:
86 """Run after each migration phase to verify data integrity."""
87
88 def validate_row_counts(self):
89 """Source and target row counts must match within tolerance."""
90 for table in self.tables:
91 source = self.source_db.count(table)
92 target = self.target_db.count(table)
93 tolerance = 0.001 # 0.1% tolerance for in-flight writes
94 assert abs(source - target) / source < tolerance, \
95 f"{table}: source={source}, target={target}"
96
97 def validate_checksums(self):
98 """Hash comparison on sampled rows."""
99 for table in self.tables:
100 sample_ids = self.source_db.sample_ids(table, n=10000)
101 for batch in chunked(sample_ids, 1000):
102 source_hash = self.source_db.hash_rows(table, batch)
103 target_hash = self.target_db.hash_rows(table, batch)
104 assert source_hash == target_hash, \
105 f"{table}: checksum mismatch in batch"
106
107 def validate_business_rules(self):
108 """Domain-specific invariants."""
109 # Example: total revenue must match
110 source_rev = self.source_db.query("SELECT SUM(amount) FROM orders")
111 target_rev = self.target_db.query("SELECT SUM(amount) FROM orders")
112 assert source_rev == target_rev, "Revenue mismatch!"
113
114 def validate_constraints(self):
115 """All FKs, unique constraints, and NOT NULLs hold on target."""
116 violations = self.target_db.check_constraints()
117 assert len(violations) == 0, f"Constraint violations: {violations}"
118```
119
120### Rollback Decision Tree
121
122```
123Migration issue detected?
124 │
125 ├─ Data loss or corruption? → IMMEDIATE ROLLBACK
126 │ Switch reads/writes back to old DB
127 │ Replay writes from new DB → old DB (if needed)
128 │
129 ├─ Performance regression? → EVALUATE
130 │ ├─ < 2x slower → optimize, do not rollback
131 │ └─ > 2x slower → rollback, investigate
132 │
133 └─ Minor data discrepancy? → FIX FORWARD
134 Run reconciliation job to sync
135 Do NOT rollback for fixable issues
136
137Rollback window: keep old DB live for 7-14 days post-cutover
138```
139
140## Anti-Patterns
141
1421. **No rehearsal** — always run the full migration on staging with production-scale data before the real cutover
1432. **Validation after cutover only** — validate continuously during dual-write phase, not just at the end
1443. **No rollback plan** — every migration needs a documented rollback procedure with defined triggers
1454. **Big bang for large datasets** — migrating 1TB+ in one shot risks extended downtime; use CDC or phased approach
1465. **Ignoring edge cases** — NULLs, empty strings, Unicode, timezone differences, and precision loss cause subtle data corruption
147
148## Quality Checklist
149
150- [ ] Source data profiled: row counts, types, nulls, edge cases documented
151- [ ] Migration strategy chosen with justification (dual-write, CDC, big bang)
152- [ ] Validation framework covers: row counts, checksums, business rules, constraints
153- [ ] Full rehearsal completed on staging with production-scale data
154- [ ] Rollback procedure documented with trigger criteria
155- [ ] Rollback window defined (keep old system live 7-14 days)
156- [ ] Dual-write conflict resolution strategy defined
157- [ ] Performance benchmarked: target system meets SLA before cutover
158- [ ] Communication plan: stakeholders notified of timeline and risks
159- [ ] Post-migration monitoring: alerts for data discrepancies for 30 days