The query came at 2:13 a.m. A schema change was needed. The fastest way forward was to add a new column.
Adding a new column to a database sounds simple. It’s not. Schema changes touch production data. They change how queries run, how indexes work, and how applications behave. Runtime performance can degrade. Deploys can fail. Migrations can lock tables.
The first step is planning. Identify where the new column fits in the model. Define the data type. Decide if it should allow nulls. Choose defaults carefully — the wrong default can cascade through the codebase. Check if you need constraints, unique indexes, or foreign keys.
The second step is execution. For small tables, an ALTER TABLE ... ADD COLUMN can run instantly. For large tables with high write traffic, you may need online schema migration tools like pt-online-schema-change or gh-ost to avoid downtime.