Adding a new column to a database table seems simple. In production, it can break queries, block writes, or cause downtime. A disciplined process ensures safety, speed, and zero data loss. This is true whether the target is PostgreSQL, MySQL, or another relational system.
Start by defining the new column with its exact data type and nullability. In many cases, adding it as nullable avoids table-wide locks. For PostgreSQL, ALTER TABLE ADD COLUMN is fast for nullable columns without default values. For MySQL, this may still require a table copy, so schedule it off-peak or use tools like pt-online-schema-change.
Avoid setting defaults inline if they require full table rewrites. Instead, add the new column empty, backfill data in controlled batches, then apply NOT NULL constraints later. This method reduces lock times and keeps production systems responsive.