Adding a column is simple in theory. In practice, it can stall deployments, lock tables, and break critical code paths. The wrong migration can block writes and cause downtime. The right one will roll out safely, without disrupting production traffic.
When creating a new column, define its data type and constraints with intent. Avoid adding defaults that require rewriting the entire table. Use NULL for initial rollout when possible, then backfill asynchronously. This reduces lock time and minimizes load.
For relational databases like PostgreSQL or MySQL, run schema changes in transactions only when guaranteed to be lightweight. Large tables benefit from online schema change tools, such as gh-ost or pt-online-schema-change, to avoid blocking queries.
Deploy new columns in multi-step migrations. First, create the column without constraints. Second, backfill data in small batches to avoid spikes in I/O. Third, add indexes and constraints after the data is complete. This ensures each step is reversible and low-risk.