The table was live in production when the request came in: add a new column. No migration plan. No downtime budget. No room for errors.
A new column sounds simple, but in real systems it can break indexes, block writes, or shove unknown defaults into critical code paths. The work is both structural and behavioral. You are not just changing schema; you are changing the shape of the data and the queries that depend on it.
First, define the column with precision. Choose a data type that matches future usage, not just current needs. Avoid nullability unless it serves a clear purpose. Set the default value deliberately; never rely on the database to guess.
Second, plan the deployment. In PostgreSQL, adding a column without a default is typically instant. Adding one with a constant default rewrites the table. That can lock rows and block transactions. To avoid that, add the column as nullable, backfill in small batches, then enforce NOT NULL only after data is complete.