2012-06-21 3 views
1

2 개의 CoreData 데이터베이스로 마이그레이션을 수행하고 싶습니다. 나는 apple developer document을 읽었다.마이그레이션 핵심 데이터 오류 코드 134130

첫 번째 데이터베이스의 경우 새 버전의 데이터베이스에 몇 가지 특성 (문자열, 정수 및 날짜 속성)을 추가했습니다. 모든 단계를 거친 후 처음으로 마이그레이션을 성공적으로 마쳤습니다.

두 번째 데이터베이스에서 새로운 버전의 데이터베이스에 특성 (문자열, 정수, 날짜, 변환 가능 및 이진 데이터 속성)을 추가했습니다. 그리고 첫 번째 데이터베이스와 같이 모든 단계를 수행하면 시스템에서 오류를 반환합니다 (134130).

if (persistentStoreCoordinator_) { 
    PMReleaseSafely(persistentStoreCoordinator_); 
} 

// Notify 
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; 
[nc postNotificationName:GCalWillMigrationNotification object:self]; 

// 
NSString *sourceStoreType = NSSQLiteStoreType; 
NSString *dataStorePath = [PMUtility dataStorePathForName:GCalDBWarehousePersistentStoreName]; 
NSURL *storeURL = [NSURL fileURLWithPath:dataStorePath]; 
BOOL storeExists = [[NSFileManager defaultManager] fileExistsAtPath:dataStorePath]; 

// 
NSError *error = nil; 
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: 
         [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, 
         [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; 
persistentStoreCoordinator_ = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel]; 
[persistentStoreCoordinator_ addPersistentStoreWithType:sourceStoreType 
              configuration:nil 
                URL:storeURL 
               options:options 
                error:&error]; 
if (error != nil) { 
    abort(); 
} 

오류가 nil이 아닌 아래 로그입니다 : 여기

코드입니다

 
Error Domain=NSCocoaErrorDomain Code=134130 "The operation 
couldn\u2019t be completed. (Cocoa error 134130.)" UserInfo=0x856f790 
{URL=file://localhost/Users/greensun/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/D10712DE-D9FE-411A-8182-C4F58C60EC6D/Library/Application%20Support/XXX/XXX.sqlite, 
metadata={type = immutable dict, 
count = 7, entries => 2 : {contents = 
"NSStoreModelVersionIdentifiers"} = {type = immutable, count = 1, values = ( 0 : {contents = ""})} 4 : {contents = "NSPersistenceFrameworkVersion"} = {value = +386, type = kCFNumberSInt64Type} 6 : 
{contents = 
"NSStoreModelVersionHashes"} = {type = immutable dict, count = 2, entries => 0 : 
{contents = "XXX"} = {length = 32, capacity = 32, bytes = 
0xfdae355f55c13fbd0344415fea26c8bb ... 4c1721aadd4122aa} 1 : 
{contents = "XXX"} = {length = 32, capacity = 32, bytes = 
0x7676888f0d7eaff4d1f844343028ce02 ... 040af6cbe8c5fd01} } 7 : 
{contents = "NSStoreUUID"} = {contents = 
"51678BAC-CCFB-4D00-AF5C-8FA1BEDA6440"}  8 : {contents = "NSStoreType"} = {contents = "SQLite"} 9 : {contents = "_NSAutoVacuumLevel"} = {contents = "2"} 10 : {contents = "NSStoreModelVersionHashesVersion"} = 
{value = +3, type = 
kCFNumberSInt32Type} }, reason=Can't find model for source store} 

내가 솔루션을 많이했지만, 그것은 작동하지 않습니다. 두 개의 새 버전 데이터베이스에 특성을 추가하고 한 번 마이그레이션하는 데 성공합니다.

답변

1

이것은 iOS5의 Apple 프레임 워크에있는 버그입니다. 귀하가 Apple iOS 개발자 프로그램의 회원 인 것으로 가정하므로 Apple Developer Forums에서이 책을 읽을 수 있습니다.

즉, 예를 들어 2 개의 영구 저장소를 사용하는 것과 같이 둘 이상의 모델을 사용하는 경우 (한 경우 만 해당) 다른 모델이 남아있는 동안 하나의 데이터 모델의 새 버전을 추가 할 수없는 경우가 있습니다 그들의 현재 버전.

Apple에 제출되었으며 중복으로 표시되었습니다. 이것이 iOS6에서 아직 수정되었는지는 모르겠습니다.

+0

답장을 보내 주셔서 감사합니다. – magichero

+0

나는 내 문제를 해결했다. SVN으로 작업 해 왔으며 Core Date의 새 버전을 만들 때 SVN은 이전 버전 데이터의 사본을 만들었습니다. 프로젝트의 SVN에서 전체 핵심 데이터를 제거하고 외부 복사본을 만들어야합니다. 그런 다음 새 핵심 데이터를 작성하고 문제를 해결했습니다. – magichero

관련 문제