The migration halted. The schema was wrong. A new column had to be added before the next deploy, and the clock was running out.
Adding a new column in production is simple in concept but dangerous in practice. It changes the shape of your data, forces updates to dependent code, and can lock tables if not handled correctly. In high-traffic systems, careless execution leads to downtime or corrupted rows.
The safest way to add a new column starts with understanding your database engine’s behavior. In PostgreSQL, adding a nullable column without a default is instant, regardless of table size. Adding a column with a default can lock and rewrite the entire table. In MySQL, the same command may block writes for seconds or minutes, depending on the storage engine and configuration. In distributed databases, the schema change must be replicated consistently across all nodes, or queries will fail.
Plan the column definition carefully. Choose the right data type and constraints. If you must add a NOT NULL column with a default value in PostgreSQL, add it in two steps: first as nullable, then update the rows in small batches, and finally add the NOT NULL constraint. This reduces lock times and avoids impacting requests. In MySQL, test on a clone before touching production.