Adding a new column to a database table is simple in theory. In production, it can be a minefield. Schema changes can lock writes, trigger downtime, or cause inconsistent data if not executed with care. The goal is zero‑downtime migrations, even under high load.
When you add a new column, always start with compatibility. Make sure your application code can handle rows both with and without the column. Deploy code that ignores the missing field first. Only after that should you alter the schema.
For large tables, adding a new column can be expensive. Some databases lock the table while they rewrite it. Use migrations that run online. In MySQL, ALTER TABLE ... ALGORITHM=INPLACE or ALGORITHM=INSTANT can help. In PostgreSQL, adding a nullable column without a default is nearly instant because it only updates metadata. Setting a default that is not NULL will rewrite every row, so add the column first, then backfill in batches.
Backfill with care. Use queues, scheduled jobs, or chunked updates with explicit limits to avoid overwhelming the database. Monitor replication lag and query performance during the process.