Adding a new column is one of the most common, and most critical, updates in a database. Done right, it’s fast, safe, and keeps production online. Done wrong, it locks rows, stalls deployments, and risks data loss. The steps are simple, but the implications run deep.
Before creating a new column, define its purpose, data type, and constraints. Know if it needs to be nullable or have a default value. In PostgreSQL and MySQL, adding a nullable column without a default is instant. But adding a column with a default value to a large table can backfill existing rows and cause downtime.
For zero-downtime schema changes, consider phased migrations. First, add the new column as nullable with no default. Then, backfill data in small batches. Finally, update constraints and defaults after the backfill completes. Many teams automate this process using migration tools or custom scripts.