Adding a new column is one of the most common schema changes, yet it can break systems if done carelessly. The right approach keeps data safe, migrations fast, and downtime at zero. The wrong approach slows deploys and risks production errors.
Start by defining the new column in a way that matches your data model exactly. Choose the correct data type. Avoid nullable columns unless required. For timestamp data, use a consistent time zone format. For text, decide early on whether it needs indexing for queries.
Run the migration with a strategy that scales. In large datasets, adding a column with a default value can lock the table. Instead, add the column first, then backfill in small batches. Use transactions carefully—big ones can cause lock contention. For high availability systems, deploy migrations online using chunking or tools like gh-ost or pt-online-schema-change.