Adding a new column is one of the most common schema changes, yet also one of the most dangerous when handled poorly. A misapplied schema migration can lock tables, block writes, or even bring down production. The goal is speed without risking downtime.
Start with a clear definition. Decide the column name, data type, nullability, constraints, and default values. Avoid changing multiple aspects of the table in one migration. Keep each change atomic so it’s reversible.
In PostgreSQL and MySQL, adding a nullable column without a default is usually fast. Adding a column with a default value can trigger a full table rewrite. On large datasets, this can stall queries and degrade performance. A safer path is to create the column as nullable, then backfill data in small batches before enforcing constraints and defaults.
For systems with high availability requirements, wrap migrations in feature flags. Deploy code that can handle both old and new schemas before running the migration. After the new column is in place and populated, remove the legacy paths.