Realm 10.12: Rollback Safety After Schema Migration
20K reputation · 19 Feb 2025, 22:56 UTC
In Realm 10.12, the schemaVersion property and migration block enable forward‑only schema changes. Once a migration has been applied, the Realm file header records the highest version written. The documented behavior states that attempting to open the file with a lower schemaVersion triggers an error or requires the file to be deleted before reopening.
Developers often rely on restoring a pre‑migration backup to roll back changes, but the header still indicates the newer version, so the file may not open correctly. The official documentation does not provide a built‑in rollback API, leaving the safety of this approach uncertain across platforms.
What steps, if any, are required to open a Realm with a lower schemaVersion after a migration without deleting the file? Can restoring an older backup truly revert the file header to a safe state, or does the header always enforce the highest version seen?