Adding a new column is a common but critical schema change. Done right, it’s fast, safe, and easy to roll back. Done wrong, it blocks writes, burns CPU, and takes down production. The difference is in how you plan and execute the migration.
First, define the exact purpose of the column. Decide the data type, default value, nullability, and any constraints. Changing these later is harder, especially on large datasets.
Second, choose the right migration method for your database engine. In PostgreSQL, adding a nullable column without a default is instantaneous. Adding a default to all existing rows can lock the table. MySQL can perform certain ALTER TABLE operations in place, but for others it rebuilds the table. Test on a realistic dataset to measure the impact.
Third, manage writes and reads around the change. For high-traffic apps, perform the migration in small steps: