The database was live. Traffic at peak load. Downtime was not an option.
A new column is one of the simplest schema changes. It is also one of the most dangerous if handled without a plan. The wrong migration can lock tables, stall queries, and slow the API to a crawl.
The core steps are straightforward. First, assess the table size and index count. On large datasets, adding a column with a default value forces a rewrite of every row. This can trigger long-running locks. Instead, add the new column as nullable with no default, then backfill data in small, controlled batches. Only after the table has the data should you set the default and constraints.
Always run the change in a staging environment with a mirror of real data volume. Use migration tools that support online schema changes. These tools, like pt-online-schema-change or native ALTER TABLE with algorithm options in MySQL and PostgreSQL, reduce lock time to near zero.