The query ran, silent and fast, and then everything stopped. A missing field. A half-broken schema. You need a new column, and you need it without breaking production.
Adding a new column to a live database is simple in concept but dangerous in practice. Schema changes can lock tables, spike CPU, and cause downtime. The safest path is to plan the migration with both code and data in mind.
First, define the new column with explicit types and constraints. Avoid adding a new column with a default that forces a full table rewrite. Use NULL defaults or handle defaults at the application level until the backfill is done. In PostgreSQL, for example:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP NULL;
Second, backfill data in controlled batches. A single massive update can lock rows or saturate I/O. Use short transactions, commit often, and monitor replication lag if you’re running replicas.