The migration script ran, but the table was wrong. A missing field. The fix was simple: add a new column.
In SQL, adding a new column changes the shape of your data. In production, it must be exact. A new column can store fresh attributes, track new states, or prepare for a feature flag. But if you do it carelessly, you risk locking tables, breaking queries, or causing silent data errors.
The syntax is direct. In PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In MySQL:
ALTER TABLE users ADD COLUMN last_login DATETIME;
But the operation’s impact depends on engine, constraints, and indexes. Null defaults can cause full table rewrites. Large tables can stall under locks. On distributed systems, replica lag can spike when the new column replicates across nodes. In CI/CD pipelines, schema changes must match the deployed application code exactly or queries will fail.