在已同步的域上运行迁移

时间:2016-10-24 23:57:52

标签: ios swift database realm realm-mobile-platform

我已经创建了一个新的对象模型,当我打开我的应用时,我收到以下错误:

*** Terminating app due to uncaught exception 'RLMException', reason: 'Invalid class subset list:
- 'Mod.generalSettings' links to class 'Setting', which is missing from the list of classes managed by the Realm
- 'Mod.contextSettings' links to class 'Setting', which is missing from the list of classes managed by the Realm
- 'Mod.accountSettings' links to class 'Setting', which is missing from the list of classes managed by the Realm'

当我关闭保存同步Realm的Realm对象服务器时,我没有收到此错误。这是在启动时运行的配置:

Realm.Configuration.defaultConfiguration = Realm.Configuration(
        syncConfiguration: (user, syncServerURL!),
        objectTypes: [Dot.self, Mod.self, Setting.self])

这让我相信我需要为远程领域运行迁移。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

您无法从客户端直接访问服务器上的Realm文件。您需要做的就是在本地运行迁移,更改将被推送到服务器。

如果您没有删除任何列,则可以像以下一样运行迁移:

Realm.Configuration.defaultConfiguration = Realm.Configuration(
        syncConfiguration: (user, syncServerURL!),
        schemaVersion: 1,
        migrationBlock: { migration, oldSchemaVersion in },
        objectTypes: [Dot.self, Mod.self, Setting.self])

我希望有所帮助!