The query hit the database like a hammer, but the table wasn't ready. You needed a new column, and you needed it without breaking production.
Adding a new column sounds simple. In most systems, it isn’t. Migrations lock writes, balloon storage, and risk downtime. The size of the table, database type, and schema design dictate how precise you must be. For high-traffic services, even a few seconds of lock time can trigger cascading failures.
The safest path starts with a plan. First, define the exact type and null constraints for the new column. Avoid defaults that force an immediate rewrite of all rows unless absolutely necessary. If possible, add the column without backfilling data in the same step. Postpone that update to a background job or a controlled batch migration.
In PostgreSQL, ALTER TABLE ADD COLUMN can be near-instant for nullable columns without defaults. In MySQL, the story varies by storage engine and version. Check if your environment supports instant DDL. Even then, test the migration in a staging system with realistic data before exposing production to risk.