Adding a new column sounds simple, but in production it is never trivial. Schema changes can block writes, lock tables, and break services. The wrong approach turns a quick update into downtime, data loss, or a rollback at 3 a.m. Knowing how to add a column safely is core to shipping reliable software fast.
First, choose the migration strategy. For small tables, an ALTER TABLE ADD COLUMN may work. For large datasets, you need an online migration to avoid full-table locks. Many relational databases, like PostgreSQL and MySQL, now support adding a new column with default values without rewriting the table. Know the exact behavior of your database engine before running the command in production.
Second, make schema changes backward-compatible. Deploy the new column before any code that writes to it. This lets the old code run until the new deployment is live and stable. Once reads and writes use the new column, run a cleanup migration to remove legacy structures.