我有一个要应用迁移的领域模型。但是,当我应用迁移时,我得到了错误
Configurations cannot be different if used to open the same file.
The most likely cause is that equals() and hashCode() are not overridden in the migration class:
在我的 Activity 类中,配置设置为:
realmConfiguration = new RealmConfiguration
.Builder(this)
.schemaVersion(0)
.migration(new Migration())
.build();
我使用领域实例来获取一些值。然后我使用以下方法应用迁移:
RealmConfiguration config = new RealmConfiguration.Builder(this)
.schemaVersion(1) // Must be bumped when the schema changes
.migration(new Migration()) // Migration to run
.build();
Realm.setDefaultConfiguration(config);
当我调用它时:realm = Realm.getDefaultInstance();
我收到上面的错误。我是否正确应用迁移?