Re: Core Data Lightweight Migration Woes
Re: Core Data Lightweight Migration Woes
- Subject: Re: Core Data Lightweight Migration Woes
- From: Brad Gibbs <email@hidden>
- Date: Sat, 21 Aug 2010 08:22:16 -0700
Well, that's the way I started doing things, but, on pages 130-131 of the book More iPhone 3 Development (written by Dave Mark & Jeff LaMarche -- your co-authors for Learn Cocoa on the Mac) make a point of saying that the new version is the unnumbered version.
In some ways, I wouldn't think it would matter. When first created, they're exact replicas, and you can change the names of both of these files. What the compiler(?) is looking for are the version hashes for each of the entities. As long as it can find both the version marked current and another version with entity hashes that match those stored in the data file to be migrated, I would think it would be able to decide which is the old version, and which is the new.
My classes are organized into folders on my desktop (and in Git). I pulled all four data models out of folders and put them at the top level of the folder hierarchy. This *seems* to have helped. Although I've still gotten the missing source model error since then, it seems to be happening less frequently.
The other thing I did was to create a new set of data while the section of code that merges the second data model in with the main data model was commented out. After the model was created, I uncommented that code and made changes to the first model and everything seems ok. It made me realize that I don't know whether the app is having a hard time finding the source model for the first model, or, if it thinks that there should be two versions of the second model. Since there's only a single version of the second model (.mom), it may be getting hung-up there, although that would seem to be more of a bug than user error.
I wish I could submit a simplified version to Apple, but, since I have no idea what's actually causing the problem and I can't seem to replicate it in the little test apps I've been making, I don't know how I'd do that. I do live about 45 minutes from Cupertino. Maybe it's time to pester Chris Hanson at the next NSCoder Night...
On Aug 21, 2010, at 7:37 AM, Jack Nutting wrote:
> On Fri, Aug 20, 2010 at 8:46 PM, Brad Gibbs <email@hidden> wrote:
>> I highlighted the .xcdatamodel and did a Design > Data Model > Add New
>> Version. That created the Config.xcdatamodeld with an unnumbered version of
>> the datamodel (Config.xcdatamodel) and a numbered copy named Config
>> 2.xcdatamodel.
>> I go into Config.xcdatamodel and add a single string attribute to one
>> entity, Clean and Build & Go. I get the missing source model error.
>
> I think you're looking at the versioning the wrong way around! The
> data model with the "2" in its name is the new one, THAT's where you
> should add new attributes etc. When your app runs, it will find the
> existing data store which is version "1", both model files (the old
> one is "1", the new one is "2"), and do the conversion for you.
>
> I don't have it in front of me, but I think that if you bring up the
> info window for each of the model files, you'll see that each shows a
> version number. Core Data will always work to bring lower-versioned
> data stores up to whatever you've marked as the current version.
>
>
> --
> // jack
> // http://nuthole.com
> // http://learncocoa.org
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden