The query hit production at 02:14, and everything broke. The schema had changed. A new column had been added.
Adding a new column sounds simple. It can be, but it’s never trivial in a live system. A careless migration can lock tables, stall writes, and cause downtime. Done right, it becomes an invisible upgrade that supports features without breaking existing code.
When you create a new column, the first task is to decide its type and constraints. Every choice has a cost. NULL vs NOT NULL changes storage and query behavior. Default values ensure consistency but can cause large writes during migration. Indexing speeds lookups but slows inserts. Data type mismatches leak bugs to production.
Plan for backward compatibility. Deploy the schema change without touching old code paths. Populate the new column in small batches to avoid load spikes. Don’t drop or rename critical columns until all code is updated and deployed. Feature flags help coordinate the shift.