The query ran. The cursor blinked. But the output was wrong because the schema was missing a new column.
Adding a new column should be fast, safe, and repeatable. Schema changes are high‑impact operations that can break production if done without care. Whether you use PostgreSQL, MySQL, or another relational database, the steps are clear: define the column type, set constraints, apply sensible defaults, and manage backfills without locking critical tables. The challenge is doing it without downtime and without corrupting data.
In PostgreSQL, ALTER TABLE ... ADD COLUMN is straightforward. But simplicity can hide risks. Adding a new column with a default value on a large table can lock writes. Instead, add the column without a default, backfill in batches, and then add the default and NOT NULL constraint. MySQL’s approach is similar, but may require ALGORITHM=INPLACE or LOCK=NONE for large datasets. Testing these changes in a staging environment with representative data is mandatory.