The database table waited, but the schema was wrong. You needed a new column, and you needed it without breaking production.
Adding a new column should be simple, but in high-traffic systems, schema changes carry real risk. The wrong migration can lock tables, stall writes, and cascade into outages. The right approach is deliberate.
First, confirm the column name and data type. Avoid generic names. Match types to their true constraints: integer for IDs, timestamp with timezone for events, varchar with a defined length for controlled strings. Never default to text without cause.
Second, plan for default values and nullability. A NOT NULL constraint with no default will fail on existing rows. Decide if historical data should be backfilled before the migration or if the column will start empty.
Third, choose the migration method. Online schema changes, such as those supported by PostgreSQL’s ADD COLUMN for low-impact additions, can be safe. For heavier changes, tools like gh-ost or pt-online-schema-change can prevent table locks.