Adding a new column sounds simple. It isn’t. Whether you’re working on PostgreSQL, MySQL, or a distributed database, the wrong approach can lock tables, block writes, or break deployments. At scale, these problems become outages.
The first decision is schema change strategy. For small non-critical tables, a direct ALTER TABLE ADD COLUMN can work. On large production tables, that same statement can cause downtime. Use tools like pg_online_schema_change or pt-online-schema-change to create the column without blocking reads and writes.
Define the column with defaults carefully. Setting a non-null default during creation can rewrite the entire table. Instead, add the nullable column, backfill data in controlled batches, then enforce constraints after completion. This reduces lock time and avoids replication lag in follower nodes.
Plan migrations so application and database changes roll out in the correct order. Deploy code that can handle both old and new schemas before creating the column. Only after the backfill and checks are done should you remove legacy paths.