In any database with live traffic, adding a new column is more than running an ALTER TABLE statement. Schema changes lock tables, impact query performance, and—when done carelessly—can break production. Understanding how to add a new column with zero downtime is critical for keeping systems stable and fast.
A new column should start with a clear definition: name, data type, nullability, default values, and indexing requirements. Avoid adding unnecessary indexes at the same time as the column; create them in a separate step to reduce lock time.
For PostgreSQL, ALTER TABLE ... ADD COLUMN is straightforward for nullable columns without defaults. Adding a NOT NULL column with a default forces a full table rewrite. To prevent downtime, first add it as nullable, backfill in batches, then enforce constraints in a later migration. For MySQL, keep in mind that some storage engines handle schema changes online, while others require table copies.