Engineering

Migrating 1M+ Records Without Downtime

Share

Database migrations are where production incidents are born. When EduCore asked us to move 2 million student records from a legacy MySQL schema to a new PostgreSQL architecture — with 200+ institutional clients live on the platform — we knew we needed a bulletproof playbook.

The Shadow Write Pattern

The core technique that made our migration safe was shadow writing: every write operation during the migration period wrote to both the old and new databases simultaneously. This let us run validation queries continuously, comparing record counts and checksums between systems without any user-facing risk.

The Playbook

Step 1: Instrument everything. Before moving a single record, add monitoring to understand your current read/write patterns, peak load times, and which tables are most frequently accessed.

Step 2: Build the migration pipeline in isolation. Test it on a production data snapshot, not on production itself. Measure how long it takes. Plan for it taking 3× longer.

Step 3: Enable shadow writes. Every new write goes to both systems. Start validating consistency immediately.

Step 4: Begin background migration of historical records. Start with the least-accessed tables, work toward the most-accessed. Validate each batch.

Step 5: Cut over reads progressively. Move 1% of read traffic to the new system. Then 10%. Then 50%. Monitor error rates at each step.

Step 6: Cut over 100% of reads. Disable shadow writes. Keep the old system warm for 2 weeks before decommissioning.

What We Learned

The EduCore migration took 6 months from planning to completion. We moved 2.1 million records with zero downtime and zero data loss. The key was patience — the instinct is always to go faster, but with database migrations, slow and validated beats fast and risky every time.

admin