The query ran. The log scrolled fast. The result set dropped on your screen—missing the field you actually needed. You need a new column, and you need it now.
Adding a new column is one of the most common database schema changes. Done right, it is quick and safe. Done wrong, it can lock tables, break queries, and bring production to a halt. The approach depends on your database engine, the size of your dataset, and whether you must keep the system online during deployment.
Start by confirming the exact name, type, and constraints of the new column. This definition should match both your application code and your migration script. Mismatched types or nullability rules are a common source of downtime bugs.
Use ALTER TABLE to add the column in SQL. In MySQL or PostgreSQL, a basic example looks like:
ALTER TABLE orders ADD COLUMN status VARCHAR(20) NOT NULL DEFAULT 'pending';
On large tables, adding a new column with a default can cause a full table rewrite. For millions of rows, that means locks and timeouts. In these cases, add the column as nullable and backfill in small batches before applying constraints. PostgreSQL 11+ supports adding a column with a constant default without rewriting the table, but test on staging before trusting it.