Adding a new column sounds simple. In production, it can be a minefield. Schema changes affect reads, writes, indexes, and storage. Without planning, they trigger long locks, downtime, or silent data corruption.
When creating a new column, start with the migration strategy. Choose between ALTER TABLE for in-place changes or shadow writes with backfill for zero-downtime. For small datasets, direct modification is fine. For large datasets, use batched updates with idempotent scripts.
Define the new column type and constraints with precision. Avoid implicit defaults unless they serve a functional purpose—every nullability or default value choice affects query plans. Decide if the new column should be indexed now or later; immediate indexing can amplify migration time, while deferred indexing can limit query performance at first.
Backfill in a controlled manner. Run background jobs that copy data in small chunks to prevent saturation of I/O and transaction logs. Monitor CPU, memory, and replication lag throughout the process.