The schema was tight, but a new column had to land without breaking production.
Adding a new column is simple in theory. It’s a single ALTER TABLE statement. But in real systems with live traffic, the wrong move can slow queries, lock writes, or cause downtime. You don’t get second chances when the table holds millions of rows.
Step one: define the column with the right data type. Choose carefully—changing types later is costly. Text, integer, boolean, or JSON? Pick the type that fits the contract you want to enforce. This keeps indexes small, queries fast, and data clean.
Step two: decide on NULL vs NOT NULL. NULL columns allow gradual backfills. If you set it to NOT NULL with no default, writes will fail until all existing rows have values. This can be dangerous in continuous deploy pipelines unless you orchestrate updates in stages.
Step three: think about defaults. Adding a column with a computed default on a huge table can lock it while values are written. Use a lightweight default or skip it until data migration is complete.