A single schema change can break a release or unlock new power. Adding a new column is one of the most common yet high-impact changes you can make to a database. Done right, it’s seamless. Done wrong, it causes downtime, data loss, and angry users.
A new column seems simple: alter the table, define the type, maybe set a default. But the details matter. Databases vary in how they handle schema changes. Some lock the table during the alteration, blocking reads and writes. Others allow concurrent modification but require extra syntax to avoid blocking. Choosing the right approach depends on your database engine, table size, and uptime requirements.
For PostgreSQL, using ALTER TABLE ... ADD COLUMN is straightforward for small tables, but for large datasets, it can trigger long locks. Adding a nullable column is typically instant because PostgreSQL only updates metadata. Adding a column with a default value in older versions rewrote the whole table; newer versions optimize this, but version awareness is key.