The database migration finished, but the data model was already falling behind. You needed a new column. Not tomorrow, not next sprint—now.
Adding a new column sounds simple. It isn’t. Schema changes impact performance, deployment time, and rollback strategies. The wrong approach can lock tables, block writes, or even bring down production traffic.
Start by defining the exact purpose of the new column. Will it store nullable values? Will it require indexing? If the column will be queried often, create the appropriate index after adding it. If it needs a default, decide between a static value or computed value. Avoid defaults that trigger heavy backfills on large datasets during deployment.
For relational databases like PostgreSQL or MySQL, use additive schema changes. This means adding the new column without dropping or altering existing ones first. Deploy the change in a migration script that runs quickly. For large tables, consider adding the column without a default, then backfill in smaller batches to reduce locks.