Adding a new column should be trivial. In reality, it can bring down production if done wrong. Schema changes on a live system risk locking tables, blocking writes, or causing downtime. The solution is to design every new column change with safety, performance, and rollback in mind.
Plan each schema change as a three-step process:
- Create the new column with defaults set to
NULLif possible. - Backfill data in batches to avoid load spikes.
- Add constraints or indexes after the data is populated.
For large databases, adding a column without locking requires online schema migrations. Tools like pt-online-schema-change or gh-ost handle the DDL in a shadow table, then apply changes without halting traffic. On cloud-managed databases, check for vendor-specific safe alter options before running migrations.