The query landed. The table was live. It needed a new column.
Adding a new column sounds simple. In production, it is not. The wrong migration locks your table for minutes or hours. Customers see errors. Processes fail. Revenue vanishes.
The core decision: online schema change vs. direct ALTER TABLE. Direct changes are fast for small datasets. On large tables, they risk blocking reads and writes. Online methods, like pt-online-schema-change or native database options, create and populate the column in parallel. The table stays responsive.
Choose your column type with care. In MySQL or PostgreSQL, adding a NULL column with no default is fast. Adding a column with a non-null default may require a full table rewrite. The rewrite is where downtime hides.
For PostgreSQL, use ALTER TABLE ... ADD COLUMN ... without a default, then backfill data with batched updates. MySQL 8.0 offers instant ADD COLUMN in many cases, but only for specific placements and without default values.