Database Reference
In-Depth Information
definitely doesn't support out of the box, which makes a custom manual migration
the proper tool for the job.
As usual, the first step in any data migration is to select the data model file in
Xcode and select
Editor\Add Model Version….
This time, create version 4 of the
data model called
UnCloudNotesDataModel v4
. Don't forget to set the current
version of the data model to v4 in the Xcode Inspector.
Open the v4 data model and add a new entity named
ImageAttachment
. Set the
class to
UnCloudNotes.ImageAttachment
. Make the following changes to
ImageAttachment:
•
Set the
Parent Entity
to
Attachment
.
•
Add a String attribute named
caption
.
•
Add a Float attribute named
width
.
•
Add a Float attribute name
height
,Add a Transformable attribute named
image
.
Set the Value Transformer Name to
UnCloudNotes.ImageTransformer
.
Having a parent entity is like being a subclass, which means ImageAttachment will
inherit the attributes of Attachment. When you set up the managed object subclass
later, you'll see this inheritance made explicit in the code.
Now that the image is stored in ImageAttachment, you can remove it from
Attachment. Select the
Attachment
entity and delete the
image
property.
That should do it for the new data model. Once you've finished, your version 4 data
model should look like this: