Adding a column to a table is one of the most common schema changes, yet it can be one of the most dangerous in production. Done wrong, it locks rows, slows queries, and tanks performance. Done right, it expands your data model without breaking uptime.
Before you add a new column, start with the schema definition in your migration file. Consider the column type, nullability, default values, and indexing. A poorly chosen data type or default can trigger a full table rewrite. For large datasets, zero-downtime migrations matter. In PostgreSQL, adding a nullable column without a default is instantaneous. Adding a column with a non-null default rewrites the table—plan carefully to avoid it on live systems.
In MySQL, ALTER TABLE operations can still block writes unless you use ALGORITHM=INPLACE or an online schema change tool. Always test the migration on a replica or staging database first. Monitor table size and query statistics before and after the change to catch regressions early.