Adding a new column is a common task, but in production it must be handled with precision. Schema changes can lock tables, block writes, and stall application requests. Done right, they scale smoothly. Done wrong, they cause outages.
First, assess the migration path. On large datasets, a simple ALTER TABLE ADD COLUMN can hold locks for minutes or hours. Use online migration tools like pt-online-schema-change or gh-ost to avoid downtime.
Second, define defaults carefully. Setting a non-null column with a default value can trigger a full table rewrite. Instead, add it nullable and backfill in small batches, then enforce NOT NULL once the data is complete.
Third, update the application code in stages. Deploy the schema change before the code depends on the new column. This prevents runtime errors when older application nodes still run without awareness of the column.