The migration script was flawless until it wasn’t. One column short. The production table stared back—mocking, immutable—until the new column was in place.
Adding a new column is simple when it’s local. In production, simplicity becomes risk. Data integrity, query performance, and deployment speed matter. A careless ALTER TABLE can lock rows, block reads, or stall writes. In a high-traffic system, that’s the moment where downtime creeps in.
Plan the schema change. Decide if the new column needs a default value or if it can be nullable. Avoid backfilling large datasets in a single transaction. Use batched updates, shadow writes, or online schema change tools to keep performance stable.
For relational databases like PostgreSQL, ALTER TABLE ADD COLUMN is fast when adding a nullable column without defaults. But watch for implicit data rewrites caused by adding defaults or constraints. In MySQL, online DDL helps, but the engine choice—InnoDB vs MyISAM—changes the locking behavior.