Adding a new column to a production database seems simple. It is not. Schema changes can block queries, lock writes, and slow the entire system. In high-volume applications, a poorly executed schema migration can cascade into outages. That is why the process matters.
A new column definition starts with precision. Choose the correct data type. Define nullability and defaults. Avoid implicit conversions that cause rewrites of every row. For large datasets, use an online migration strategy:
- Create the new column as nullable.
- Backfill in controlled batches.
- Add constraints only after the data is complete.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is often fast, but adding defaults that are not NULL will rewrite the table. In MySQL, ALTER TABLE may be blocking, depending on storage engine and version. Understand these details before running the statement.