Adding a new column is one of the most common schema changes. Done right, it’s invisible to the user. Done wrong, it can lock tables, stall writes, or crash services. The goal is to make the change quickly, safely, and without downtime.
First, define the column in your migration. Use explicit types. Avoid nullable fields unless necessary. Set sensible defaults to avoid backfilling massive tables under load.
Second, plan for deployment. On large datasets, adding a column may trigger a table rewrite. This can block queries. Use tools that support online migrations—such as pt-online-schema-change, gh-ost, or native database features like PostgreSQL’s ADD COLUMN when it’s safe. Always test in staging with production-like volume.