The table was live, production data flowing, and the schema needed to change. A new column had to be added—fast, safe, and without breaking anything.
Adding a new column in a database is simple in syntax and complex in effect. It changes the structure, impacts queries, and can lock or slow tables. On high-traffic systems, a careless ALTER TABLE ADD COLUMN can trigger downtime. The key is knowing how your database engine handles schema changes at scale.
In PostgreSQL, adding a nullable column with a default that’s not NULL can rewrite the entire table. To avoid that, add the column as nullable, then backfill in controlled batches, and finally set the default. In MySQL, online DDL options like ALGORITHM=INPLACE and LOCK=NONE reduce disruption, but storage engines differ in behavior. Many NoSQL systems, like MongoDB, treat schema changes as implicit, but updating old documents still requires careful migration planning.