Adding a new column to a production database is simple in theory. In practice, it can cause downtime, lock tables, or break application code. A safe deployment means balancing schema changes, data consistency, and application availability.
When you add a new column, start with an explicit ALTER TABLE statement. Most relational databases—PostgreSQL, MySQL, SQL Server—support adding a column in-place. But on large datasets, this can lock writes or even block reads. Use online DDL tools, background migrations, or zero-downtime techniques to avoid service disruption.
If the new column needs a default value, be careful. Setting it at creation time can force a table rewrite, which slows everything down. Instead, create the column without the default, backfill data in batches, then add the default constraint afterward. This sequence reduces lock time and keeps queries responsive.
On the application side, deploy code that can handle both the old schema and the new. Feature flags are useful here. First, deploy code that ignores the column. Then add the column to the database. Then deploy code that uses the column. This avoids runtime errors caused by schema drift.