Adding a new column is one of the most common changes in database work. It looks simple. It can be fast. But the wrong approach can lock tables, stall queries, or blow up your deploy window. The right approach keeps your data safe and your app online.
First, define the column in a migration file. Keep the name clear, lowercase, and free of spaces. Example:
ALTER TABLE orders ADD COLUMN shipped_at TIMESTAMP;
For large tables, consider adding the column as nullable first. Then backfill data in batches to avoid locking the table. In high-traffic systems, wrap operations in transactions only when necessary. Plan for indexes—adding them later can be safer than creating them during the initial alter.