The migration broke at 2:14 a.m., and the error pointed to a missing column. A single absent field. Everything downstream was locked.
Adding a new column to a database table should be simple, but the details matter. The wrong method can cause downtime, trigger locks, or corrupt data. The right method keeps systems responsive while the schema evolves.
First, define the purpose of the new column. Avoid generic names. Use consistent naming rules. Ensure the data type aligns with expected scale and precision. If it will hold large text, choose a type like TEXT or VARCHAR with appropriate length. If it will store timestamps, match the exact format used elsewhere.
Second, confirm the default value and nullability. Setting a default avoids issues in existing rows. Understand how your database engine applies defaults during schema changes. Some engines rewrite the entire table; others optimize in place.
Third, plan for rolling deployment. On high-traffic systems, adding a column may require phased migration: