Adding a new column is one of the most common schema changes, but also one of the most dangerous if done without care. Schema migrations on production systems can lock tables, slow queries, or block writes. When your dataset grows into millions or billions of rows, a naive ALTER TABLE can bring down a service in seconds.
To add a new column safely, start by planning the exact change. Define the column name, type, nullability, and default value. Avoid adding defaults with costly computations. In PostgreSQL and MySQL, adding a nullable column without a default is often metadata-only, which runs fast. If you must set a default, add the column first, then backfill in batches to avoid table rewrites.
For large tables, online schema change tools like gh-ost or pt-online-schema-change help keep systems responsive. These tools create a shadow table with the new column definition, copy data asynchronously, and swap names at the end. This allows you to test queries against the shadow table before committing the change.
Adding a new column should also involve application-level coordination. Deploy code that supports both the old and new schema during rollout. Write paths should handle the absence of the column gracefully until migrations finish. Read paths should tolerate null or missing values. This approach allows rollback without downtime.