The database was ready. The schema was clean. Then the spec changed, and you needed a new column.
Adding a new column sounds straightforward. It isn’t. In production systems, this step can break queries, increase latency, or freeze deployments. Done wrong, it can trigger locks that stall writes and block reads. Done right, it’s invisible to users.
First, define the column’s purpose. Avoid generic names. Use consistent naming schemes and align with established data types. Know the impact on storage size, indexing, and query plans.
Second, control the migration. On large tables, a blocking ALTER TABLE can be disastrous. Use tools that perform online schema changes, such as pt-online-schema-change for MySQL or native non-blocking migrations in PostgreSQL. Break changes into two deployments: add the new column as nullable, then populate it in batches.