The query landed. The log showed a schema mismatch. The database needed a new column.
Adding a new column is one of the most common schema changes. It seems simple. It’s not. A careless migration can lock tables, stall writes, or flood error logs. Done right, it’s near-instant and safe in production.
First, define the new column with clear data types. Avoid nullable defaults unless required. Use explicit defaults to control backfill behavior. If the table is large, avoid adding the column with a default value in one step—this forces a full table rewrite. Instead, add the column null, then backfill in chunks, then alter to set the default.
For relational databases like PostgreSQL or MySQL, online schema change tools can prevent downtime. Use ALTER TABLE with care. Wrap migrations in transactions where supported, but avoid long locks on high-traffic tables. Always test the migration on a clone of production data to understand performance impact.