The fix was simple: add a new column. The hard part was doing it safely, without downtime or broken queries in production.
A new column changes the schema. In a small table, it’s a quick operation. In a large table under constant load, it can lock writes, stall deployments, or cause replication lag. Knowing how to add one with precision means less risk and faster delivery.
Start by defining the exact data type and constraints. Defaults that require backfilling will rewrite the entire table. On massive datasets, that’s not acceptable. Use nullable columns first, backfill in controlled batches, then add NOT NULL constraints when complete.
In relational databases like PostgreSQL and MySQL, ALTER TABLE is the standard command. But each handles locks differently. PostgreSQL allows adding a new nullable column without a full table rewrite. MySQL may still cause table copy unless you use ALGORITHM=INPLACE and appropriate settings.