Adding a new column is one of the most common schema changes. It can be trivial in development and dangerous in production. Done wrong, it blocks writes, locks tables, and slows queries. Done right, it ships without downtime and sets the stage for features you haven’t built yet.
Start by defining the column name, type, and constraints with intention. A vague name creates confusion. A mismatched type causes errors. Default values matter—decide if the column should be nullable or have a default to avoid backfilling headaches.
In relational databases like PostgreSQL or MySQL, ALTER TABLE ADD COLUMN is straightforward, but the details vary. On small tables, this runs instantly. On large tables in production, it can lock reads and writes. Check your migration tool’s documentation. Many support concurrent or online DDL, but they often have hidden limits you must understand.
For Postgres:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This runs fast if no default is set. If you must add a default, consider a two-step migration: create the new column without the default, then update rows in small batches, then set the default for new inserts.