简体   繁体   English

在同步的领域上运行迁移

[英]Run Migration on synced Realm

I've created a new object model and when I open my app I get the following error: 我创建了一个新的对象模型,当我打开应用程序时,出现以下错误:

*** 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'

I don't get this error when I shut down the Realm Object Server that holds my synced Realm. 关闭保存同步的Realm的Realm对象服务器时,没有出现此错误。 This is the config that runs on launch: 这是在启动时运行的配置:

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

This leads me to believe I need to run a migration for my remote realm. 这使我相信我需要为远程领域进行迁移。 How can I do this? 我怎样才能做到这一点?

You don't have direct access to Realm files on the server from the client. 您无法从客户端直接访问服务器上的Realm文件。 All you need to do is run a migration locally and the changes will be pushed up to the server. 您需要做的就是在本地运行迁移,更改将被推送到服务器。

If you're not deleting any columns, you can run a migration as simply as: 如果您不删除任何列,则可以像下面这样简单地运行迁移:

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

I hope that helps! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM