CURRICULUM PREVIEWRevision 1 · Open for reviewReview the full course
CONNECTING THE PIECES8 min read

Migrations with a rollback story

Treat schema evolution as part of the release.

Before you beginef-core

The idea

Schema changes and application versions can overlap during deployment. For a new required field, first add a compatible nullable column, deploy code that writes it, backfill existing rows, and only then enforce the constraint. Run migrations with a dedicated identity; the web app should not own the schema.

Follow the flow

Make it concrete

This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.

Focused example
text
Expand: add nullable booking_reference
Deploy: write booking_reference for new rows
Backfill: fill existing rows in bounded batches
Verify: check missing and duplicate values
Contract: enforce NOT NULL and uniqueness

Decisions that matter

  • Prefer forward-compatible changes during rolling deployments.
  • A migration transaction does not make every large backfill cheap or nonblocking.
  • Record backup evidence, expected locks, and a tested recovery procedure.

Your turn

Why is dropping the old column in the same deployment risky, even if the new code no longer uses it?

Reveal a worked answer

An old process may still be serving traffic and a binary rollback may need the column. Wait until all supported versions have stopped reading it and the recovery window has closed. Test restoration from a backup rather than assuming a down migration recovers data.

Keep exploring

One more piece connected.

Mark this lesson complete when you can explain the idea.