Adding a new column in a production database is not just an ALTER TABLE command. It is impact analysis, zero downtime strategy, and fail-safe rollback planning. When done wrong, queries stall, indices break, and latency spikes. Done right, it slips into place without anyone noticing.
First, define the column with precision. Use the smallest data type possible. Decide on NULL handling upfront to avoid meaningless defaults or cascade errors. Add constraints only if they are critical to data integrity; otherwise, defer to application-level validations to keep migrations lightweight.
Second, plan the migration path. If the table is large, adding a column can lock rows and block writes. Use online schema changes or tools like gh-ost, pt-online-schema-change, or native database features for safe, non-blocking updates. Test these migrations against a copy of production data to uncover edge cases before they hit the real system.