Adding a new column should be fast, safe, and repeatable. Yet in many production databases, it can be risky. Locking tables, slowing queries, breaking deployments—these are the traps. Avoiding downtime takes a clean, deliberate process.
First, define exactly what the new column will store. Set the correct data type from the start. Keep it nullable if you are rolling out in phases. Non-null columns with defaults can lock large tables as values backfill, so plan migrations carefully.
Second, write explicit migration scripts. In PostgreSQL, ALTER TABLE ADD COLUMN is simple, but for big datasets you may need to add the column without a default, then backfill in batches. In MySQL, watch for table rebuilds. Use pt-online-schema-change or a similar tool for zero-downtime changes.