You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we are using a Room database, we are allowed to use .fallbackToDestructiveMigration() option.
Setting this option, Room tries to execute the migrations we specified. If any error occurs, Room will delete the schema.
How can we achieve this with Realm. .deleteRealmIfMigrationNeeded() is just dropping the database. It just ignores the migration.
The text was updated successfully, but these errors were encountered:
We don't have explicit support for it right now, but you could just catch the RealmMigrationNeededException and delete the file in that case, i.e. something like this:
val config = RealmConfiguration.Builder()
.schemaVersion(1)
.migration(MyMigration())
.build()
val realm = try {
Realm.getInstance(config)
} catch(ex: RealmMigrationNeededException) {
Realm.deleteRealm(config)
Realm.open(config)
}
When we are using a Room database, we are allowed to use .fallbackToDestructiveMigration() option.
Setting this option, Room tries to execute the migrations we specified. If any error occurs, Room will delete the schema.
How can we achieve this with Realm. .deleteRealmIfMigrationNeeded() is just dropping the database. It just ignores the migration.
The text was updated successfully, but these errors were encountered: