Adding a new column in production is not just an ALTER TABLE away. Schema migrations must be planned with care, especially for large datasets or high-traffic systems. Database locks, replication lag, and data backfills can all turn a simple change into an incident.
First, choose the correct column type. Think about precision, nullability, and default values. Each choice affects storage size, indexing, and query performance. Avoid hidden costs by testing the impact on typical workloads.
Second, design for a zero-downtime migration. In MySQL or PostgreSQL, adding a new column can lock the table for writes if not handled correctly. Use online schema change tools, background migrations, or phased rollouts. Write application code that can handle both the old and new schema until the change is complete.
Third, backfill data with care. For large tables, run the backfill in small batches to prevent performance degradation and reduce replication lag. Monitor metrics during the process to detect issues early.