Adding a new column to a database table should be simple. In practice, it can break everything if handled poorly. Schema changes run in production carry risk: downtime, locks, lost data. The key is to plan the addition, execute it with zero downtime, and verify before deploying dependent code.
Start with a clear migration strategy. Assign the column name, type, default value, and nullability. For PostgreSQL, adding a nullable column with no default is fast. Setting a default on creation will backfill the entire table, which can block writes. In MySQL, be aware of older versions that rebuild the table for certain ALTER TABLE operations. Always check the exact behavior of your database version.
For zero-downtime changes, add the new column in one migration and populate it in a separate background job. Deploy the code that writes to the new column only after the data is fully populated. If you need a non-nullable constraint, add it in a final migration once all rows meet the condition. This sequence lets you avoid long locks and service interruption.