当前位置: 动力学知识库 > 问答 > 编程问答 >

How to compare Realm schemas from Android and iOS realm file

问题描述:

I've implemented database in realm on Android an iOS. I'm hardly sure that they are the same but if I'm replacing file from iOS and getting Realm instance using this file I get RealmMigrationNeededException. Is there any way to compare schemas in realm files from Android and iOS? If I'm doing the same action with file from another Android device it works.

Edit:

After adding empty Migration:

public class Migration implements RealmMigration {

@Override

public long execute(Realm realm, long version) {

return version;

}

}

I get: "Primary key not defined for field 'id' in existing Realm file. Add @PrimaryKey." Both platforms have 'id' field implemented as primary key.

网友答案:

There doesn't exit a tool yet that can output the entire schema unfortunately. You can use our Realm Browser for IOS, which will show you some of it, but if I remember correctly it will not show you e.g which fields are indexed: https://itunes.apple.com/us/app/realm-browser/id1007457278?mt=12

The migration exception should give you some idea what is wrong though?

分享给朋友:
您可能感兴趣的文章:
随机阅读: