Adding a new column sounds simple. In production, it can break queries, crash services, or lock critical tables. The right approach depends on the database engine, table size, and uptime requirements. Small tables may allow an immediate ALTER TABLE without issues. Large tables in high-traffic systems need a more surgical plan.
For relational databases like PostgreSQL or MySQL, a blocking ALTER TABLE can freeze writes. Online schema change tools like gh-ost or pg_online_schema_change avoid downtime by creating a shadow table, copying data in chunks, and swapping it in. This method controls lock duration and keeps services alive during migration.
When you add a new column, define its nullability, default values, and indexing strategy. A NOT NULL column with a default on a large table can cause a full rewrite—impacting performance for minutes or hours. In PostgreSQL, using a default with no immediate table rewrite (ALTER TABLE ... ADD COLUMN ... DEFAULT ...) only works for constant expressions since version 11. In MySQL, default values behave differently and must be tested before production rollout.