The query finished running before the schema migration did. You open the log, scroll back, and there it is: the missing piece was a new column.
Adding a new column should be simple. In practice, it can lock tables, block writes, and stall deployments if handled poorly. Databases handle structure changes differently, and knowing the mechanics is the difference between a clean rollout and a production freeze.
When you add a new column in PostgreSQL with a default value, the database rewrites the entire table. This is immediate for small datasets but destructive for large ones under load. Avoid defaults in the ALTER TABLE statement and backfill data in batches instead. Use ALTER TABLE … ADD COLUMN with no constraints first, then add indexes or NOT NULL later in separate, safe steps.
MySQL has more nuanced behavior with ALGORITHM=INPLACE and LOCK=NONE options. Still, even with online DDL, some changes fall back to a full table copy. Always confirm the actual execution plan. These migrations should be tested against real dataset sizes to identify locking and performance thresholds before release.