Adding a new column is one of the most common schema changes in modern databases. It should be fast, safe, and predictable. In reality, it often blocks deploys, locks tables, and risks downtime if not done with care. Whether you use PostgreSQL, MySQL, or a cloud-native database, the way you add a column can decide if your release sails or stalls.
The process starts with defining the new column in your migration. Specify the correct data type from the start—altering it later can be expensive. Decide if it should allow NULLs, what default values make sense, and if it needs an index. Avoid adding indexes in the same migration if the table holds millions of rows; separate them to reduce lock times.
For large datasets, use operations that run in constant time. In PostgreSQL, adding a nullable column without a default is fast. Adding a column with a default on a big table before version 11 rewrites the whole table, so break it into two steps: add the column, then run an UPDATE in batches. In MySQL, adding a new column can still trigger a table copy unless you use ALGORITHM=INPLACE where supported.