Data轻量级迁移有多少迁移步骤

Data轻量级迁移有多少迁移步骤

本文介绍了Core Data轻量级迁移有多少迁移步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的iPhone应用程序使用Core Data和轻量级迁移。

I use Core Data and lightweight migration for my iPhone app.

假设我为应用程序创建了3个版本的数据模型。一个用户安装了我的应用程序的早期版本,其数据模型版本仍然是v1。当用户将应用更新到具有数据模型版本v1,v2和v3的最新版本时,更新期间发生了什么?

Suppose I have created 3 versions of the data model for the app. One user installed the early version of my app and its data model version is still v1. When the user update the app to the latest version which has the data model version v1,v2 and v3, what happened during the update?

sqlite数据库从v1迁移到v2,然后从v2迁移到v3?

The sqlite database migrate from v1 to v2 first and then migrate from v2 to v3? Or it just jump from v1 to v3?

推荐答案

在内部,我相信Core Data轻量级迁移会将更改应用到每个后续版本但为了您的目的,您可以将其视为直接发生在最终版本的迁移。据我所知,在轻量级迁移过程中,在版本之间没有钩子拦截和运行代码。

Internally, I believe Core Data lightweight migration will apply the changes to each subsequent version in order, but for your purposes you can think of it as a migration that happens directly to the final version. To my knowledge there are no "hooks" to intercept and run code between versions during a lightweight migration.

如果你需要修改数据或添加新数据,动态模型版本并相应地做出反应。

If you need to alter data or add new data, you should determine the model version dynamically and react accordingly.

这篇关于Core Data轻量级迁移有多少迁移步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 03:01