The schema was ready. The migration sat waiting, like a loaded command. All it needed was a new column.
Adding a new column in a production database can feel routine, but the details decide whether it’s safe or if it takes the system down. The process starts with understanding the exact change. Define the column name, data type, nullability, and default. Avoid implicit casts or large default values in high-traffic tables. These can lock rows for too long and trigger latency spikes.
In SQL, adding a new column is straightforward:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In development, this runs instantly. In production, it can be slower. Database engines must rewrite metadata, adjust indexes, and sometimes rewrite entire tables depending on the column definition. For large datasets, the ALTER TABLE lock time can block reads and writes.
For PostgreSQL, adding a nullable column without a default is usually safe. It stores no data until values are written. Adding a column with a default value, especially on big tables, can be dangerous — it rewrites every row. MySQL’s behavior depends on the storage engine. InnoDB can handle certain operations instantly, but not all. Check the execution plan before deploying.