The schema was live. Production. Millions of rows moving through it. We needed a new column.
Adding a new column seems simple. It is not. A careless migration can lock tables, cause downtime, or break dependencies buried in years of code. The right approach avoids these traps.
First, define the new column precisely. Decide on its name, data type, nullability, and default value. Ensure it fits logically into the database schema. Avoid changing existing columns during this step.
Next, introduce the column in a backward-compatible way. Create it as nullable or with a safe default. This prevents application errors. Merge the migration into production during low-traffic windows or using an online migration tool.