Adding a new column is one of the most common schema changes in application development. Done right, it’s fast and safe. Done wrong, it can block production, break queries, and corrupt data.
Start by declaring the new column in your schema definition. Choose the correct data type and constraints. For high-traffic tables, default values and nullability must be decided with care. A non-null column with no default forces a full rewrite on every row at creation time, which can lock the table for minutes or hours depending on size.
Use migrations with clear up and down definitions. Name them so the change is obvious in your version control history. Apply the migration to staging first, run smoke tests, and validate the schema against your application logic before merging.
On large datasets, consider adding the new column in phases. First, add it as nullable. Then backfill the data in small batches to avoid locking and replication lag. Finally, enforce constraints once the column is fully populated.