Adding a new column is one of the most common schema changes in software development. Done right, it’s fast and safe. Done wrong, it can lock tables, block writes, or bring down production. This guide shows how to add a new column without downtime and without risking data integrity.
Identify the target table and confirm its size. Large tables require extra care. In PostgreSQL, ALTER TABLE ADD COLUMN is simple, but adding a column with a default value can rewrite the entire table. Avoid that cost by adding the column without a default, then backfilling in batches. In MySQL, adding a column may require a full table copy unless you use ALGORITHM=INPLACE. These details matter when every millisecond counts.
Use a migration tool that manages schema changes in production. Apply the change in isolation, verify queries, and update application code to handle the new column as nullable until the backfill is complete. Always measure before and after—the performance impact of a new column can ripple into indexes, query plans, and replication lag.