tan
1 hour ago · Tech · hide · 0 comments

Core Data does automatic schema migration for certain schema changes which are simple and straightforward. For other scenarios we will have to do manual schema migration. In this post we will see how to perform manual schema migration. I will demonstrate this taking example of the schema migration I had done for my app API Tester Pro (API Zen). In the first version of the model I have two properties in the EWorkspace entity. One is syncDisabled which is a date field and another is isSyncEnabled which is boolean. We are not setting any default value in the first model version, but we need to change that and have default values. So we are performing data migration to have these default values set for existing data. 1. Add new version for the model file 1.1 Let's say current model is at v1 and we are upgrading it to v2. 1.2 Open .xcdatamodeld. 1.3 Editor > Add Model Version.... 1.4 Name it say, APITesterPro 2. 1.5 Make sure APITesterPro 2 is set as the current version. 2. Add mapping…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.