• 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: [Leopard] Core Data model versioning vs. NSPersistentDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Leopard] Core Data model versioning vs. NSPersistentDocument


  • Subject: Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
  • From: Pierre Bernard <email@hidden>
  • Date: Thu, 1 Nov 2007 17:23:33 +0100

Now this is odd:

I have added some more debugging output.

MLogString(@"sourceModel: %@", [[*error userInfo] valueForKeyPath:@"sourceModel.versionIdentifiers"]);
MLogString(@"destinationModel: %@", [[*error userInfo] valueForKeyPath:@"destinationModel.versionIdentifiers"]);
MLogString(@"same model: %@", ([[*error userInfo] valueForKeyPath:@"sourceModel"] == [[*error userInfo] valueForKeyPath:@"destinationModel"]) ? @"YES" : @"NO");
MLogString(@"equivalent model: %@", ([[[*error userInfo] valueForKeyPath:@"sourceModel"] isEqual:[[*error userInfo] valueForKeyPath:@"destinationModel"]]) ? @"YES" : @"NO");
MLogString(@"sourceModel: %@", [[*error userInfo] valueForKeyPath:@"sourceModel.entityVersionHashesByName"]);
MLogString(@"destinationModel: %@", [[*error userInfo] valueForKeyPath:@"destinationModel.entityVersionHashesByName"]);
MLogString(@"reason: %@", [[*error userInfo] valueForKeyPath:@"reason"]);



I have copied the output below. The upshot is that Core Data correctly recognizes that there are 2 different models. Il correctly lists the entities for each model. Oddly enough it shows twice the same version identifier although it should be different. It does nt find the migration model although it exists.


2007-11-01 17:21:10.849 HoudahSpot[1933:10b] Document.m:629 sourceModel: {(
"2.0"
)}
2007-11-01 17:21:10.850 HoudahSpot[1933:10b] Document.m:630 destinationModel: {(
"2.0"
)}
2007-11-01 17:21:10.851 HoudahSpot[1933:10b] Document.m:631 same model: NO
2007-11-01 17:21:10.852 HoudahSpot[1933:10b] Document.m:632 equivalent model: NO
2007-11-01 17:21:10.853 HoudahSpot[1933:10b] Document.m:633 sourceModel: {
Attribute = <68dbab1b e0e367d6 77b02233 8b70442e bb4322d3 7fa1aad6 aebf6377 229ea4fb>;
AttributeValue = <8953cc81 d80ad1a4 c221af0c ef365199 a22a7513 f3a30496 139946cd 77172c8d>;
MetaAttribute = <c74fc402 010fec75 10e0c3bf d5ca39a8 7f5bffef 8ca67089 bb3aa0fa 5fa14144>;
OrderedScope = <2f9405d0 4a331352 70d9a772 cf3d8629 edd2c033 11206d72 271d53b8 9bb817e1>;
QueryItem = <92fb4797 2622383a 99169460 a1458608 6ce3e96b 1b9e1111 8e6388e4 f5d33bed>;
QueryLeaf = <78992a6c 7724a71d 21f36dca 9501929a 5ead1066 b3420239 c520d0ef d748247f>;
QueryNode = <03de248d fd4198dc 68d33064 5ad79ef3 5a7cbcef f376e8a8 512a2834 ddd93037>;
Scope = <146feb1a 2255255e 174f7ec5 03f003b5 c3ea593a a1baea0d b47075c6 b4a9ccff>;
}
2007-11-01 17:21:10.854 HoudahSpot[1933:10b] Document.m:634 destinationModel: {
Attribute = <68dbab1b e0e367d6 77b02233 8b70442e bb4322d3 7fa1aad6 aebf6377 229ea4fb>;
AttributeValue = <8953cc81 d80ad1a4 c221af0c ef365199 a22a7513 f3a30496 139946cd 77172c8d>;
ColumnAttribute = <f49ae37f effce04e a6f5f382 b08ab3a2 68a18bc0 ef8cd598 992e0333 5d62ab38>;
LimitAttribute = <c1bfbe7f 99537e64 7ffe013b 4d77f015 e02153b7 ecf3179f c3b8a937 c04e69d0>;
MetaAttribute = <c74fc402 010fec75 10e0c3bf d5ca39a8 7f5bffef 8ca67089 bb3aa0fa 5fa14144>;
OrderedColumnAttribute = <8e062ace 634467a9 7566153c c648d74d cc821c3c 2ebc9675 133f79e8 cd1f0368>;
OrderedExclusionScope = <12732537 2411cfbf 4c8d6dce a46d557a d38254fe 008518f9 b70f4755 fb55a12e>;
OrderedLimitAttribute = <247757f5 24ee13ca c8526e87 2022ede1 247f3393 cec0083a 14573611 49e2594a>;
OrderedScope = <2f9405d0 4a331352 70d9a772 cf3d8629 edd2c033 11206d72 271d53b8 9bb817e1>;
QueryItem = <92fb4797 2622383a 99169460 a1458608 6ce3e96b 1b9e1111 8e6388e4 f5d33bed>;
QueryLeaf = <78992a6c 7724a71d 21f36dca 9501929a 5ead1066 b3420239 c520d0ef d748247f>;
QueryNode = <03de248d fd4198dc 68d33064 5ad79ef3 5a7cbcef f376e8a8 512a2834 ddd93037>;
Scope = <146feb1a 2255255e 174f7ec5 03f003b5 c3ea593a a1baea0d b47075c6 b4a9ccff>;
}
2007-11-01 17:21:10.855 HoudahSpot[1933:10b] Document.m:635 reason: Can't find mapping model for migration



Pierre


On Nov 1, 2007, at 3:27 PM, Pierre Bernard wrote:

Hi!

Thanks Malcolm.

I got at least one step closer to the solution, still it does not work yet.

Here is where I pass the appropriate option to the store coordinator:

- (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url
ofType:(NSString *)fileType
modelConfiguration:(NSString *)configuration
storeOptions:(NSDictionary *)storeOptions
error:(NSError **)error
{
NSMutableDictionary *options = [NSMutableDictionary dictionaryWithDictionary:storeOptions];

[options setObject:[NSNumber numberWithBool:YES] forKey:NSMigratePersistentStoresAutomaticallyOption];


BOOL ok = [super configurePersistentStoreCoordinatorForURL:url
ofType:fileType
modelConfiguration:configuration
storeOptions:options
error:error];

if (*error != nil) {
NSLog(@"sourceModel: %@", [[*error userInfo] valueForKeyPath:@"sourceModel.versionIdentifiers"]);
NSLog(@"destinationModel: %@", [[*error userInfo] valueForKeyPath:@"destinationModel.versionIdentifiers"]);
NSLog(@"same model: %@", ([[*error userInfo] valueForKeyPath:@"sourceModel"] == [[*error userInfo] valueForKeyPath:@"destinationModel"]) ? @"YES" : @"NO");
NSLog(@"equivalent model: %@", ([[[*error userInfo] valueForKeyPath:@"sourceModel"] isEqual:[[*error userInfo] valueForKeyPath:@"destinationModel"]]) ? @"YES" : @"NO");
NSLog(@"reason: %@", [[*error userInfo] valueForKeyPath:@"reason"]);


	}

   return ok;
}

The problem is that ok == NO. I.e. migration fails and I have no idea where to look for hints or explanations. The error is pretty meaningless except for its userInfo dictionary. Moreover the error is swallowed on the way up to the user where it appears as a generic "cannot open" message.

Now what I can't understand is why both source and destination models have the same versionIdentifiers. I guess this would also explain why the mapping model is not found.

Best,
Pierre


On Nov 1, 2007, at 3:23 AM, mmalc crawford wrote:


On Oct 31, 2007, at 4:00 PM, Pierre Bernard wrote:

Does NSPersistentDocument handle versioning issues or do I need to hook into document loading to call the migration manager myself?
What is the recommended approach for using the migration manager within the NSDocument architecture?


It's just as described here <http://developer.apple.com/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmInitiating.html >.

mmalc


--- Pierre Bernard http://www.bernard-web.com/pierre http://www.houdah.com



_______________________________________________

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

--- Pierre Bernard http://www.bernard-web.com/pierre http://www.houdah.com



_______________________________________________

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


  • Follow-Ups:
    • Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
      • From: mmalc crawford <email@hidden>
    • Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
      • From: email@hidden
References: 
 >Re: [Leopard] Core Data model versioning vs. NSPersistentDocument (From: Pierre Bernard <email@hidden>)

  • Prev by Date: Re: Extend QuickLook to other standard files
  • Next by Date: Transistion Effects from Interface Builder
  • Previous by thread: Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
  • Next by thread: Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
  • Index(es):
    • Date
    • Thread