The query hit the database, but the schema had changed. You needed a new column, and you needed it fast.
Adding a new column is one of the most common schema changes in production systems. Yet it can be dangerous if done without thought. The way you create, populate, and index it will decide whether your deployment is smooth or if it locks up a critical table under load.
First, define the exact data type the column needs. Avoid defaults that seem harmless. A VARCHAR(255) may waste memory, and a TEXT column can slow queries. Match the column’s type and size to its data.
Second, plan the nullability and default values. If you backfill millions of rows, a poorly chosen default can cause massive writes. In high-traffic systems, add the column without filling it, then backfill in batches. This keeps transactions short and avoids blocking.
Third, handle indexes carefully. Adding an index at the same time as the column can cause long locks. It is often safer to add the column, backfill data, then create the index in a separate migration.