Adding a new column is one of the most common schema changes, yet it can be one of the most dangerous if done without care. Databases respond differently depending on engine, size, and indexing. In PostgreSQL, adding a nullable column without a default is fast. Adding one with a default can rewrite the entire table. In MySQL, even simple changes can lock the table if not executed with an online DDL strategy.
Before creating a new column, define its type, constraints, and default values with intention. Avoid implicit conversions that may break application logic. Ensure your migration script runs within a controlled environment and is tested against production-sized data. Use feature flags to control when new code starts reading or writing to the column. This reduces the risk of query errors or incompatible deployments.
When adding a column to a large table, measure and plan for the potential lock time. Leverage CREATE INDEX CONCURRENTLY in PostgreSQL or ALGORITHM=INPLACE in MySQL where possible. If downtime is unacceptable, stage your changes: add the column, backfill values asynchronously, then add constraints.