Adding a new column is one of the most common schema changes in production. It sounds simple, but in large systems the wrong approach can block writes, lock tables, and throw errors into live traffic. Done right, it’s fast, safe, and invisible to the user.
Start by defining the new column in your migration script with clear defaults. Always set NULL or a default value to avoid altering existing rows in a way that requires a full table rewrite. Use ADD COLUMN with care; on some databases it’s metadata-only, on others it’s a blocking operation.
If you’re working in PostgreSQL, adding a column with a non-null default will rewrite the entire table in older versions. Postgres 11+ optimizes this by storing the default in metadata instead, reducing downtime. On MySQL, make sure to use ALGORITHM=INPLACE when possible to minimize locks.
For high-traffic systems, online schema change tools like gh-ost or pt-online-schema-change can keep the application running while the column is added. These tools create a shadow table with the new column, copy rows in chunks, and swap at the end. This reduces lock time and avoids table-wide stalls.