Adding a new column is one of the most common schema migrations. It looks simple, but if you get it wrong, it can lock tables, slow queries, and disrupt production. The right approach makes the change safe, fast, and easy to roll back.
A new column changes the structure of your table. Before adding it, define its type with precision. Choose default values with care. If the column is nullable, know what that means for future constraints. If it’s non-nullable, backfill the data before enforcing the constraint.
In relational databases like PostgreSQL and MySQL, adding a column can trigger a full table rewrite if defaults are written directly. This can block writes for minutes or hours on large tables. To avoid downtime, add the column without a default first, update rows in small batches, then add the default and constraints. This pattern works for most production environments.
In distributed systems or high-traffic APIs, schema changes must coordinate with application code. Deploy in steps: