Adding a new column is one of the most common schema changes. Done well, it’s invisible to users. Done wrong, it locks tables, spikes CPU, and freezes deploys. The details matter.
First, understand your database engine’s behavior. In PostgreSQL, a new column with a default value can rewrite the entire table. In MySQL, certain data types trigger a full table copy. Both can block writes depending on the version and configuration.
Second, always run schema migrations with strict sequencing. Deploy the schema change first without defaults or constraints, then backfill the data in controlled batches. After the backfill is complete, add defaults and constraints in separate migrations. This reduces downtime risk and replication lag.
Third, avoid altering large tables during peak load. Schedule migrations for off-hours or use tools like gh-ost or pt-online-schema-change for MySQL, or PostgreSQL’s ADD COLUMN with no default followed by an UPDATE in batches.