Adding a new column to a database table should be simple. In most systems, it isn’t. Migrations can block writes, lock tables, or trigger downtime if your data size is large. Your schema must evolve, but you cannot stop production. The path is careful and exact.
In SQL, the core operation is clear:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works for small datasets. On massive tables, you need an online schema change. Tools like pt-online-schema-change or gh-ost create a shadow table, copy data chunk by chunk, and switch over with minimal lock time. These tools let you add columns to MySQL without bringing down your app.
PostgreSQL supports adding new columns instantly when they have a default of NULL and no constraints. But adding a column with a non-null default will rewrite the whole table, which can stall production. The safest route is to add the column without a default, backfill in batches, then add constraints.