Adding a new column is common, but doing it right under load takes more than running ALTER TABLE. Schema changes can lock rows, slow queries, or cascade failures across dependent services. The right approach depends on your database engine, table size, and uptime requirements.
In PostgreSQL, adding a new column with a default value rewrites the entire table. For large datasets, that’s a problem. A safer pattern is:
ALTER TABLE users ADD COLUMN last_active_at TIMESTAMP NULL;
UPDATE users SET last_active_at = NOW() WHERE id IN (...);
Then backfill in small batches with a background job. Once complete, apply NOT NULL or set defaults. For MySQL, similar principles apply. With large tables, use ALGORITHM=INPLACE or tools like pt-online-schema-change to reduce locking.