Adding a new column to a production database demands speed, safety, and precision. Schema changes are simple in theory, but in practice they touch code, migrations, indexes, and data integrity all at once. A careless ALTER TABLE can lock writes, slow reads, and cascade failures through dependent services.
Plan the change. Identify the exact column name, type, and constraints. Check how it will interact with existing indexes, foreign keys, and queries. Use a migration tool that supports transactional DDL where possible, or phased rollouts when it doesn’t. For large datasets, add the column without defaults, backfill in batches, then enforce constraints.
In PostgreSQL, a new column with a DEFAULT on a huge table rewrites the entire table. Avoid that. Instead, create the column as nullable, backfill values in chunks with UPDATE statements, then set the default and NOT NULL. For MySQL, know the storage engine’s locking behavior—InnoDB supports some online changes, but always test on a copy first.