Adding a new column to a database should be fast, predictable, and safe. In production, it often isn’t. The challenge grows when tables have millions of rows, strict uptime requirements, and constraints tied to multiple dependent services. A single blocking ALTER TABLE can lock writes, stall queries, and bring the system to a halt.
To create a new column without downtime, start by choosing an approach that matches your database engine and workload. For PostgreSQL, avoid default values on large tables during the initial ADD COLUMN. Create the column as nullable, then backfill in controlled batches. Once the data is populated, set the default and add constraints. For MySQL, use online schema change tools like pt-online-schema-change or native ALGORITHM=INPLACE options where available.
Plan migrations to minimize replication lag. Monitor performance metrics before, during, and after the schema change. If your application reads from replicas, ensure the new column is deployed to all nodes before depending on it in code. Always wrap schema changes in feature flags so you can roll forward or disable features quickly if something fails.