• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core data migration question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core data migration question


  • Subject: Re: Core data migration question
  • From: mmalc Crawford <email@hidden>
  • Date: Tue, 07 Apr 2009 14:09:51 -0700


On Apr 7, 2009, at 12:28 PM, Timothy Larkin wrote:

I think that Jon is asking whether he should give a version number to his data model, and not whether he should create a second version of his data model. If this is in fact his question, then I think the answer is yes, because this will make it easier, if he needs to migrate at some time in the future, to identify which data model version he migrating from.

Again, no.


You don't need to specify a version number for the previous model, Core Data ignores it:


<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmVersioning.html#//apple_ref/doc/uid/TP40004714 >

"As a developer, your perspective is typically that a version is denoted by an identifier—a string or number, such as “9A218”, “2.0.7”, or “Version 1.1”. [...]
Core Data, on the other hand, treats these identifiers simply as “hints”."


In particular:

"Notice that Core Data ignores any identifiers you set. In the examples above, Core Data treats version 1.0 (Figure 1) and 1.1 (Figure 2) as being compatible."



You typically don't need to retrieve the source model yourself:

"If your application does support versioning and you choose to use the default migration process, you simply use addPersistentStoreWithType:configuration:URL:options:error: as described in “The Default Migration Process.” The fundamental difference from the non-versioned approach is that you instruct the coordinator to automatically migrate the store to the current model version by adding an entry to the options dictionary where the key is NSMigratePersistentStoresAutomaticallyOption and the value is an NSNumberobject that represents YES."

<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmInitiating.html#//apple_ref/doc/uid/TP40005509 >



Even if you do want to initiate migration yourself, you ask Core Data to find the source model:



NSManagedObjectModel *sourceModel =
[NSManagedObjectModel mergedModelFromBundles:bundlesForSourceModel
forStoreMetadata:sourceMetadata];
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmCustomizingTheProcess.html#//apple_ref/doc/uid/TP40005510-SW4 >


mmalc

_______________________________________________

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


References: 
 >Core data migration question (From: "Jon C. Munson II" <email@hidden>)
 >Re: Core data migration question (From: mmalc Crawford <email@hidden>)
 >Re: Core data migration question (From: Jon Munson II <email@hidden>)
 >Re: Core data migration question (From: mmalc Crawford <email@hidden>)
 >Re: Core data migration question (From: Timothy Larkin <email@hidden>)

  • Prev by Date: Re: SQLite and Unicode
  • Next by Date: Re: SQLite and Unicode
  • Previous by thread: Re: Core data migration question
  • Next by thread: Keynote Scripting
  • Index(es):
    • Date
    • Thread