The query hit the database like a hammer, but the schema could not keep pace. You need a new column.
Adding a new column is not just another line in a migration script. It changes the shape of the data, the way queries run, and the way your application thinks. Get it wrong, and you can lock tables, spike load, or break production. Get it right, and the change slides into place with zero downtime.
First, define the column clearly. Choose a name that aligns with existing conventions. Decide the data type based on actual use, not guesses. Every choice here controls performance, storage, and indexing later.
Second, plan the migration. In relational databases like PostgreSQL and MySQL, adding a new column with a default value can lock the table. For large datasets, run a two-phase approach: add the column without a default, backfill in batches, then set the default in a lightweight alter.