在Android项目中升级领域

我目前在我的一个Android项目中运行Realm Version 0.82.0.我没有触及Realm很长一段时间,直到我最近注意到它们在此期间上升到版本2.0.2.我想升级我的Realm版本,不幸的是,我不知道从我的旧版本升级到当前版本是否会起作用或破坏我的代码.

我特别关注迁移,因为自我的代码以来迁移API似乎有所改变,而且我不确定如果我只是更新我的版本,我的迁移是否会中断.遗憾的是,没有关于在其网页上升级Realm版本的文档.

有没有人有升级Realm的经验,特别是两个主要版本的版本增加?

解决方法:

可以在他们的Github上的CHANGELOG.MD中获得重大更改列表.

然而,值得注意的是,路上有很多突破性变化,尤其是0.89.0.

从0.82.0到5.1.0是以下(这是目前最稳定的版本):

0.82.0:

BREAKING CHANGE: Fields with annotation @PrimaryKey are indexed automatically now. Older schemas require a migration.

(0.82.2在这里最稳定,但它在Blackberry设备上不起作用.在Blackberry上使用的第一个稳定版本是0.87.2.)

在0.86.0中,您可以使用添加索引到带注释的字段

@Override
public void migrate(final DynamicRealm realm, long oldVersion, long newVersion) {
    RealmSchema schema = realm.getSchema();
    // version check and stuff
    RealmObjectSchema personSchema = schema.get("Person");
    personSchema.addIndex("fieldName");

0.83:

BREAKING CHANGE: Database file format update. The Realm file created by this version cannot be used by previous versions of Realm.

BREAKING CHANGE: Removed deprecated methods and constructors from the Realm class.

BREAKING CHANGE: Introduced boxed types Boolean, Byte, Short, Integer, Long, Float and Double. Added null support. Introduced annotation @Required to indicate a field is not nullable. String, Date and byte[] became nullable by default which means a RealmMigrationNeededException will be thrown if an previous version of a Realm file is opened.

哦,孩子,这是一个很好的. NULL支持.

原始的盒装类型变得可用.盒装类型默认为可以为空.所有String,Date和byte []必须使用@Required或schema.setNullable(“fieldName”,nullability)进行注释,并使它们都可以为空.

0.84.0:

添加了异步查询.在架构方面没有什么新东西.

0.85.0:

BREAKING CHANGE: Removed RealmEncryptionNotSupportedException since the encryption implementation changed in Realm’s underlying storage engine. Encryption is now supported on all devices.

BREAKING CHANGE: Realm.executeTransaction() now directly throws any RuntimeException instead of wrapping it in a RealmException (#1682).

BREAKING CHANGE: RealmQuery.isNull() and RealmQuery.isNotNull() now throw IllegalArgumentException instead of RealmError if the fieldname is a linked field and the last element is a link (#1693).

这里没有什么重要的,但是:

Setters in managed object for RealmObject and RealmList now throw IllegalArgumentException if the value contains an invalid (unmanaged, removed, closed, from different Realm) object (#1749).

这是一个有趣的.以前只是失败了,所以这是最好的.但它也是Realm最大的限制.

0.86.0:

BREAKING CHANGE: The Migration API has been replaced with a new API.

BREAKING CHANGE: RealmResults.SORT_ORDER_ASCENDING and RealmResults.SORT_ORDER_DESCENDING constants have been replaced by Sort.ASCENDING and Sort.DESCENDING enums.

BREAKING CHANGE: RealmQuery.CASE_SENSITIVE and RealmQuery.CASE_INSENSITIVE constants have been replaced by Case.SENSITIVE and Case.INSENSITIVE enums.

BREAKING CHANGE: Realm.addChangeListener, RealmObject.addChangeListener and RealmResults.addChangeListener hold a strong reference to the listener, you should unregister the listener to avoid memory leaks.

BREAKING CHANGE: Removed deprecated methods RealmQuery.minimum{Int,Float,Double}, RealmQuery.maximum{Int,Float,Double}, RealmQuery.sum{Int,Float,Double} and RealmQuery.average{Int,Float,Double}. Use RealmQuery.min(), RealmQuery.max(), RealmQuery.sum() and RealmQuery.average() instead.

BREAKING CHANGE: Removed RealmConfiguration.getSchemaMediator() which is public by mistake. And RealmConfiguration.getRealmObjectClasses() is added as an alternative in order to obtain the set of model classes (#1797).

BREAKING CHANGE: Realm.addChangeListener, RealmObject.addChangeListener and RealmResults.addChangeListener will throw an IllegalStateException when invoked on a non-Looper thread. This is to prevent registering listeners that will not be invoked.

Added new Dynamic API using DynamicRealm and DynamicRealmObject.

Added Realm.getSchema() and DynamicRealm.getSchema().

new Migration API, using DynamicRealm instead of Realm.getTable().

某些内容已重命名,如果结果集仍然有效,则应取消注册更改侦听器.但是值得注意的是,你仍然应该为你的RealmResults保留一个字段变量,因为Realm的Context只有一个弱引用.

0.87.0:

RX支持.没有要紧的.

0.87.2:

Removed explicit GC call when committing a transaction (#1925).

最后,Realm又恢复了稳定!

上一篇:java – 领域和自动增量行为(Android)


下一篇:Android领域查询关系