Adding a new column in a live production environment is simple in concept but dangerous in practice. Schema changes can lock writes, stall queries, or trigger unexpected side effects. Choosing the right strategy—online DDL, background migrations, or batched backfills—can mean the difference between a smooth deploy and an outage.
Start by assessing the database engine. In MySQL, ALTER TABLE ADD COLUMN can be fast with InnoDB if the change is metadata-only, but becomes blocking with certain types. PostgreSQL handles ADD COLUMN safely for nullable additions with defaults set to NULL, but populating a default value for each row will rewrite the table. Plan the operation to avoid full-table locks.
When adding a new column with non-null constraints, consider creating it as nullable first, backfilling the data in controlled batches, then enforcing constraints in a separate migration. This reduces the risk of timeouts and contention. Version your application code to handle both old and new schemas until the migration is complete.