• 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
Core Data Manual Migration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data Manual Migration


  • Subject: Core Data Manual Migration
  • From: Yvan BARTHÉLEMY <email@hidden>
  • Date: Fri, 11 Sep 2009 18:43:01 +0200

Hello,
I need to implement manual migration in order to chain migrations. I
have compiled every mapping model from a version to the next one. All
my models are included in my resources (in a .momd bundle). My code
determines the model version used to create the document
metadataForPersistentStoreOfType:URL:error: and
isConfiguration:compatibleWithStoreMetadata:. with success.
Once the version is determined, I determine the migration path using
the model name (if I have found that the document is using model A,
and that current is C, I now I should use AtoB and then BtoC mapping
models).
Once I have manually got my file to be migrated, source model,
destination model, mapping model. I cannot successfully migrate using
NSMigrationManager.

I have configured NSMigrationManager following the steps described in
Core Data Migration Programming Guide - Customizing the Migration
Process:

NSMigrationManager *mManager = [[NSMigrationManager alloc]
initWithSourceModel:srcModel destinationModel:destModel];
NSString *storePath = [NSTemporaryDirectory()
stringByAppendingPathComponent:@"(A document being migrated)"];

if ([[NSFileManager defaultManager] fileExistsAtPath:storePath]) {
	// Removing previous item because unless, core data will try to
append data rather overwriting
	[[NSFileManager defaultManager] removeItemAtPath:storePath error:&error];
}

NSURL *storeURL = [NSURL fileURLWithPath:storePath];
NSURL *backupURL = [NSURL fileURLWithPath:[[[storePath
stringByDeletingPathExtension]  stringByAppendingString:@"~"]
									 stringByAppendingPathExtension:[storePath pathExtension]]];

[mManager migrateStoreFromURL:URL type:nil options:0
withMappingModel:mModel toDestinationURL:storeURL destinationType:nil
destinationOptions:0 error:&error];

if (error) {
  NSLog(@"An error occured while manually migrating document: %@", error);
  NSLog(@"UserInfo: %@",[error userInfo]);
}

The process fails here and the log then contains the following:
An error occured while manually migrating document: Error
Domain=NSCocoaErrorDomain Code=134110 UserInfo=0xf336960 "An error
occured during persistent store migration."
[6871:813] Error: {
    reason = "Can't add source store";
}

I don't understand what does mean Can't add source store, and how
should I configure my Migration Manager to perform my migration
successfully.

Does anyone can explain to me what is happening ?

Thanks in advance
Yvan BARTHELEMY
_______________________________________________

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

  • Prev by Date: Re: Subversion and Interface Builder
  • Next by Date: Re: NSSegmentedControl with square edges
  • Previous by thread: Re: NSSegmentedControl with square edges
  • Next by thread: re: Core Data Manual Migration
  • Index(es):
    • Date
    • Thread