【发布时间】:2015-08-02 10:02:32
【问题描述】:
Android 有一种方法可以实现这一点,但我仍然对接近 iOS 感到困惑。 我不想在每次有新更新时都进行迁移,所以如果是这样,我更喜欢 clear db 重新开始。
我发现此question 与此相关
我只能使用此代码进行迁移吗?
// Notice setSchemaVersion is set to 1, this is always set manually. It must be
// higher than the previous version (oldSchemaVersion) or an RLMException is thrown
[RLMRealm setSchemaVersion:1
forRealmAtPath:[RLMRealm defaultRealmPath]
withMigrationBlock:^(RLMMigration *migration, uint64_t oldSchemaVersion) {
// We haven’t migrated anything yet, so oldSchemaVersion == 0
if (oldSchemaVersion < 1) {
// Nothing to do!
// Realm will automatically detect new properties and removed properties
// And will update the schema on disk automatically
}
}];
【问题讨论】:
-
此功能请求正在github.com/realm/realm-cocoa/issues/1692 进行跟踪。
标签: ios migration database-migration realm realm-migration