Adding a new column is simple until you do it in a production system serving thousands of requests per second. Schema changes can block writes, lock tables, or spike CPU. They can slow your users’ queries to a crawl if you misstep. That’s why adding a new column requires a plan that works under load without downtime.
Start by inspecting the schema and its dependencies. Map every query touching this table. Adding a nullable column is safer than adding one with a default value that forces a rewrite of the entire table. For large datasets, use tools like gh-ost or pt-online-schema-change to run migrations without locking. In PostgreSQL, consider ADD COLUMN with DEFAULT NULL followed later by an UPDATE in batches to populate data.
Test the migration with production-like data. Measure row lock times, transaction logs, and replication lag. Monitor error rates in staging. You want zero disruption when the migration goes live.