Adding a new column to a production database is simple in description but dangerous in reality. You must preserve data integrity, avoid downtime, and keep performance steady under live traffic. The wrong approach can lock tables, break queries, or cause silent data loss.
Start with a clear migration plan. In SQL, the typical pattern for adding a new column is:
ALTER TABLE orders ADD COLUMN fulfilled_at TIMESTAMP NULL;
This works for small tables. In large tables, it can cause blocking writes and reads. To avoid this, use online schema changes offered by tools like gh-ost, pt-online-schema-change, or cloud database features.
Always define defaults and nullability explicitly. Decide if the new column should allow NULL values or if you’ll populate it with a default. If backfilling data, do it in batches to prevent load spikes.