Adding a new column is one of the most common changes in a production database. It should be simple, but bad planning can break queries, lock tables, or bring down entire services. When you add a column to an existing table, you change not just the schema but the contract your systems rely on.
The safest way to add a new column is to treat it as part of a migration, not a quick patch. Declare the column with a default only if your database supports instant defaults without rewriting existing rows. Otherwise, add it nullable, backfill in small batches, and then enforce the constraint. This prevents downtime and excessive locking.
For large datasets, use online schema changes. On PostgreSQL, ADD COLUMN is generally fast if it’s nullable. On MySQL, choose ALGORITHM=INPLACE to avoid a copy table operation. For distributed databases, confirm that replicas can handle schema version drift before deployment.
Your application code must be aware of the new column before or at the same time the migration runs. Feature flags let you roll out new writes without breaking old reads. Avoid deploying code that depends on the column before it exists in every environment.