Adding a new column can be simple or it can bring production to a halt. The difference is in how you design, run, and roll out the change. In relational databases like PostgreSQL, MySQL, and MariaDB, ALTER TABLE ADD COLUMN is straightforward for small datasets but can lock large tables for seconds or even hours. On high-traffic systems, seconds matter. Hours are deadly.
The first step is to understand the schema and the load on that table. Check indexes, triggers, and constraints. Adding a nullable column without a default is almost instant in most modern databases because the system just updates metadata. Adding a column with a default value can rewrite the entire table, blocking reads and writes. That’s why many teams add the column as nullable, backfill the data in batches, then add the default and constraints in a separate migration.
For zero-downtime deployments, run schema changes in ways that keep code and database in sync. Deploy code that can handle both the old schema and the new column before you add it. After the column exists, backfill in small chunks to avoid spikes in CPU, disk, or replication lag. Once complete, deploy the code that depends on the column’s data. This three-phase approach prevents race conditions and rollback nightmares.