The migration ran smooth until the schema refused to bend. The query needed a new column.
Adding a new column in a live database sounds simple. It is not. Every decision can affect performance, uptime, and data integrity. A careless ALTER TABLE on a large table can block reads and writes for minutes—or hours. You need a plan.
First, define the exact data type and constraints. Know if the column should allow null values, have a default, or be indexed. This shapes both storage and query execution plans. Avoid adding indexes during the same migration if downtime matters; create them in a separate step.
Second, choose the right migration strategy. On small tables, a direct ALTER TABLE ADD COLUMN is fine. On large, critical tables, use an online schema change tool like pt-online-schema-change or gh-ost. These create the new column without locking the table, copying data in the background.