Adding a new column to a database table sounds simple, but it can fracture production if done without care. Schema changes are one of the few deploys that can lock a table, block writes, or break downstream services. The wrong approach can trigger hours of downtime. The right approach can ship instantly.
First, assess the table size and query patterns. On large tables, a blocking ALTER TABLE ADD COLUMN can halt traffic. In MySQL and Postgres, check if the column has a default value or NOT NULL constraint—these can force a full table rewrite. On production, that’s a risk you cannot take blindly.
For PostgreSQL, adding a nullable column without a default is fast, even at scale. Assign the default in a separate UPDATE ... WHERE migration with batching to avoid long locks. For NOT NULL, populate all rows first, then add the constraint in its own transaction.
For MySQL (and MariaDB), use ALGORITHM=INPLACE or INSTANT where supported. Avoid adding defaults that cause storage engines to rewrite the table. Verify engine compatibility—InnoDB supports instant column add in many cases, but not all.