Schema mismatch error during Realm.open() after version increment
0 reputation · 02 Jun 2020, 15:06 UTC
Schema Versioning in Atlas Device SDK
When updating a local database schema in Realm, increasing the schemaVersion typically triggers a migration process during the Realm.open() call. If the version is incremented in the code but no migration block is provided to handle the structural changes, the SDK fails to open the file.
Migration Constraints
For small applications aiming for zero-downtime updates, there is a need to distinguish between additive changes—such as adding optional properties—and destructive changes that require data transformation. While additive changes may not always necessitate a complex migration block, the migrationRequired flag indicates a discrepancy between the disk schema and the current code definition.
Given these behaviors in the Atlas Device SDK, what is the precise mechanism for determining if a version bump is strictly necessary for additive-only schema changes? Additionally, how does the SDK handle the migrationRequired state when the schema is updated without an explicit version increment?