Adding a new column is one of the most common changes in database evolution, but it is also one of the most dangerous. The wrong approach can stall deployments, block queries, and create inconsistent data. Done right, it feels instant, safe, and invisible to the users.
When adding a new column in production, the first rule is to ensure backward compatibility. Applications reading the table must handle the column’s absence until it is ready. This means deploying code that does not depend on the column first, then altering the schema. Columns can be nullable or have default values to prevent breakage.
On large datasets, adding a column can lock the table. For high-traffic systems, that is unacceptable. Use online schema change tools or features built into your database engine to avoid downtime. In PostgreSQL, adding a nullable column without a default is fast; adding a column with a non-null default rewrites the table, which can be slow. In MySQL, use ALTER TABLE ... ALGORITHM=INPLACE when possible.
Plan the migration in stages: