Adding a new column to an existing database table is one of the most common schema changes. It sounds simple, but the cost can spike in production if done without care. Lock contention, slow migrations, and mixed application states can lead to downtime or corrupted queries.
The clean way starts with a direct DDL operation if your database supports it without locking. In PostgreSQL, ALTER TABLE users ADD COLUMN last_login TIMESTAMP; runs fast for nullable fields without defaults. In MySQL, ALTER TABLE may lock the table depending on engine and version. Test it on a staging dataset the size of your real one before running in production.
If you need a default value or non-null constraint, add them in separate steps. First, create the new column as nullable with no default. Then backfill the values in small batches. Finally, apply the constraint once all rows meet it. This avoids long locks and lets you roll forward without downtime.