RealmMigrationNeededException during schema version mismatch
20K reputation · 26 Mar 2021, 20:48 UTC
In Realm Java/Kotlin, the RealmConfiguration relies on the schemaVersion to determine if the on-disk database structure matches the current object models. When the version in the Realm file exceeds the version defined in the configuration, the system prevents access to avoid data corruption.
A specific challenge arises in environments where different application versions may access the same database file. Since Realm does not natively support rolling back a schema to a previous version once a migration has been committed to the file, a version mismatch creates a blocking state.
Given that the schema version is stored within the Realm file itself, what is the documented behavior for handling a scenario where a client with an older schema version attempts to open a file already migrated to a newer version? Is there a mechanism to maintain backward compatibility without destructive resets?