A schema version identifies the state of a Realm Schema at some point in time. Realm Database tracks the schema version of each realm and uses it to map the objects in each realm to the correct schema.
Schema versions are integers that you may include
in the realm configuration when you open a realm. If a client
application does not specify a version number when it opens a realm then
the realm defaults to version
Increment Versions Monotonically
Migrations must update a realm to a higher schema version. Realm Database throws an error if a client application opens a realm with a schema version that is lower than the realm's current version or if the specified schema version is the same as the realm's current version but includes different object schemas.
A local migration is a migration for a realm that does not automatically Sync with another realm. Local migrations have access to the existing Realm Schema, version, and objects and define logic that incrementally updates the realm to its new schema version. To perform a local migration you must specify a new schema version that is higher than the current version and provide a migration function when you open the out-of-date realm.
With the SDK, you can update underlying data to reflect schema changes using manual migrations. During such a manual migration, you can define new and deleted properties when they are added or removed from your schema. The editable schema exposed via a DynamicRealm provides convenience functions for renaming fields. This gives you full control over the behavior of your data during complex schema migrations.
Migrations During Application Development
During development of an application,
RealmObject classes can
change frequently. You can use Realm.deleteRealm() to
delete the database file and eliminate the need to write a full
migration for testing data.