Cloud & DevOps
•
September 22, 2026
•
5 min read
•
25 views
Zero-Downtime Database Migrations at Enterprise Scale
A battle-tested blueprint for altering tables with hundreds of millions of records without blocking reads or causing lock contention.
Running an `ALTER TABLE` on a 50-million-row production database can lock tables for hours, cascading into server exhaustion and total platform outage.
Here is the 4-phase migration pattern we employ at FLOPY.IN:
### Phase 1: Expand
Add new columns as nullable or with benign defaults. Never drop or rename columns in the same release.
### Phase 2: Dual-Writing
Update the application layer to write to both old and new columns. Read traffic continues to consume the legacy column.
### Phase 3: Backfilling
Execute throttled background workers to backfill legacy rows during low-traffic maintenance windows using cursor pagination:
```sql
UPDATE users SET new_column = legacy_column WHERE id > ? ORDER BY id ASC LIMIT 500;
```
### Phase 4: Contract
Switch all read queries to the new column, verify metrics in SiteMonitor, and safely remove legacy code in the subsequent deployment.
Here is the 4-phase migration pattern we employ at FLOPY.IN:
### Phase 1: Expand
Add new columns as nullable or with benign defaults. Never drop or rename columns in the same release.
### Phase 2: Dual-Writing
Update the application layer to write to both old and new columns. Read traffic continues to consume the legacy column.
### Phase 3: Backfilling
Execute throttled background workers to backfill legacy rows during low-traffic maintenance windows using cursor pagination:
```sql
UPDATE users SET new_column = legacy_column WHERE id > ? ORDER BY id ASC LIMIT 500;
```
### Phase 4: Contract
Switch all read queries to the new column, verify metrics in SiteMonitor, and safely remove legacy code in the subsequent deployment.
Written by
Discuss Enterprise Architecture →
Gaurav Kumar