Adding a new column is one of the most common database changes, but small mistakes can stall deployments or break production. The right approach depends on the database engine, schema state, and migration strategy.
In SQL, adding a new column is simple in isolation:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
But that’s the happy path. Once you factor in null defaults, backfills, and concurrent access, the operation becomes more complex. In PostgreSQL, adding a nullable column is usually instant. Adding a column with a default on a large table can lock writes. MySQL behaves differently—some versions rewrite the entire table.
Plan for growth. A new column should have clear naming, a data type optimized for queries, and constraints enforced at the right layer. If the new data will be populated in real time, set the column nullable at first, backfill asynchronously, then enforce NOT NULL in a second migration. This reduces locking risk.