Knowledgebase

Changing the Database Without Downtime Print

  • downtime, database, migration, errors, guide, howto, solution, zillionkinghost
  • 0

Schema changes on a live system.

WHY IT IS DIFFICULT

The application and the schema must both work during the change.

WHAT BREAKS THINGS

Renaming a column Removing a column still referenced Adding a constraint existing data violates Operations that lock a large table

WHAT THE SAFE PATTERN IS

Add the new structure Write to both old and new Migrate existing data in batches Switch reading to the new Stop writing the old Remove the old, later

WHY IN STAGES

Each step works with the version deployed before and after it.

WHAT THAT ENABLES

Rolling back without losing data.

WHAT TO AVOID

Combining a schema change and a code change that depends on it, in one release.

WHAT TO BATCH

Backfilling data, so nothing is locked for long.

WHAT TO TEST

The migration against a copy of production, timed.

WHY TIMED

A migration that takes hours is an outage.

WHAT TO CHECK BEFORE RUNNING

That it can be stopped and resumed That it is safe to run twice

WHAT TO MONITOR DURING

Lock waits Replication delay Error rate

WHAT TO HAVE READY

A way to stop it.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot