Rolling out a breaking schema change

Persistence Senior Swift 5.9+ iOS 17+ Reviewed By Alok Singh

Order the steps

Put these rollout steps in order.

  • Write the migration: lightweight where possible, custom where data changes
  • Test it on real store copies from each supported app version
  • Add a new schema version without editing the shipped one
  • Ship with progress UI, telemetry and a recovery path
Hint 1 of 1

You can't change what users already have.

Choose an answer, then open Show answer below to check it.

Show answer

Answer: C A B D

  1. Add a new schema version without editing the shipped one Old stores must still be readable as the old version.
  2. Write the migration: lightweight where possible, custom where data changes Choose the simplest migration that preserves data.
  3. Test it on real store copies from each supported app version Fresh installs never exercise the migration.
  4. Ship with progress UI, telemetry and a recovery path Users mustn't be stuck or crash if it fails.

30-second answer

Version the schema, prefer lightweight migrations, and use a staged or custom migration where data must be transformed. Test migrations against real copies of old stores from every supported version, run them before the UI touches data, show progress for long ones, and monitor failures. Keep a recovery path: re-sync from the server or start fresh without crashing.

Practise saying it · 60 s. No recording, just a timer

Explain how you ship a schema change.

Say your answer out loud, then check which of these points you covered:

  • Version the schema
  • Lightweight vs custom
  • Test on real data
  • Monitor and recover

Deep dive

SwiftData: VersionedSchema + SchemaMigrationPlan with MigrationStage.custom.

Core Data: model versions, mapping models, or staged migration (iOS 17).

Migrations can be slow on big stores; never run them on the main thread at launch without UI.

Never edit an already-shipped schema version.

Common mistakes

  • Testing only a fresh install.
  • Crashing when migration fails.

Senior take & follow-ups

Seniors treat migrations like a release: tested on real data, monitored, with a fallback.

Follow-up questions

Think of your answer first, then open the hint.

  1. What is a lightweight migration?

    Show hint

    Changes the framework can infer, like adding an optional attribute.

  2. What if migration fails?

    Show hint

    Recover from the server or reset, with telemetry.

Suggest a fix if something here is wrong or out of date.