The query ran. The table loaded. The old schema would not hold. You need a new column, and you need it without breaking production.
Adding a new column to a database table is simple in theory. In practice, it can lock rows, spike CPU, or disrupt a live system if handled carelessly. The right process depends on your database engine, data size, and uptime requirements.
In PostgreSQL, ALTER TABLE ADD COLUMN is fast for small datasets and empty defaults. For large tables, avoid default values during the initial change. Add the column as nullable first, then backfill in small batches to prevent long transactions. Finally, apply constraints or defaults.
In MySQL with InnoDB, watch out for metadata locks. Use ALTER TABLE ... ALGORITHM=INPLACE where available, or gh-ost/pt-online-schema-change for zero-downtime migrations. Always check if your engine supports instant adds for empty columns; MySQL 8.0 often does.