The migration was done, but the numbers still didn’t add up. The fix was simple: a new column.
Adding a new column in a database is a common but critical operation. Whether you use PostgreSQL, MySQL, or a modern cloud database, the steps are straightforward—but the implications are deep. Schema changes affect performance, integrity, and deployment. Done wrong, they cause downtime or data loss. Done right, they become invisible: part of a resilient system that can evolve without breaking.
In SQL, ALTER TABLE is the standard way to add a new column. For example:
ALTER TABLE orders ADD COLUMN processed_at TIMESTAMP NULL;
This creates a nullable processed_at field in the orders table. You can set defaults, constraints, and indexes to match your use case. Choosing proper data types and defaults matters as much as naming, since these decisions will shape query patterns and storage.
In PostgreSQL, adding a column without a default is fast. Adding one with a non-null default will rewrite the entire table, which can be slow on large datasets. In MySQL, ALTER TABLE often requires a full table lock unless you use specific features like ALGORITHM=INPLACE. These engine-level details determine whether your change is seamless or whether it halts production writes.