Adding a new column is deceptively simple. Done wrong, it can stall queries, lock tables, or break production in quiet and catastrophic ways. Done right, it’s a clean migration with zero downtime.
Start with the definition. Know exactly what the new column will hold: data type, nullability, default value. Avoid ambiguous types. Ensure constraints and indexes fit future queries.
Choose your migration strategy based on your database engine. In PostgreSQL, adding a nullable column is fast. In MySQL, bigger tables can cause lock time. For large datasets, use an additive change first, then backfill rows in batches. Track progress and prevent long-running locks.
Write migrations idempotently. Every run should produce the same schema without error. Keep schema changes in source control and tie them to application release cycles. Test with production-like data before touching live systems.