Adding a new column to a database table is not just a schema change — it is a production event. Done wrong, it locks tables, blocks writes, and brings down apps. Done right, it ships with zero downtime and no data loss.
Start by defining the new column in your migration script. Use a nullable field or a default value to avoid locking large tables during the alter operation. For high-traffic systems, split the migration into two steps: first add the column without constraints, then backfill data in small batches. Only when the backfill is complete should you add indexes or foreign keys.
If your database supports it, use online DDL tools or features like PostgreSQL’s ADD COLUMN with default expressions that avoid writing to every row. For MySQL, tools like pt-online-schema-change can avoid blocking writes during deployment. Always test the migration on a copy of production data to surface timing issues.