4

現在 Integer 16 として設定されている 1 つの属性を持つ Core Data モデルがあります。現在、属性名を変更してそのタイプを変更したいと考えていますが、現在のデータは保持したいと考えています。名義変更も無事完了し、問題なく動いております。

データ型を変更しようとすると、次の非常に長いエラーが表示されます。これを解決するにはどうすればよいですか?

2012-07-10 19:33:06.298 Medicine Tracker[5170:707] Unresolved error Error Domain=NSCocoaErrorDomain Code=134140 "The operation couldn’t be completed. (Cocoa error 134140.)" UserInfo=0x2ae140 {reason=Can't find or automatically infer mapping model for migration, destinationModel=(<NSManagedObjectModel: 0xf694e20>) isEditable 0, entities {
Log = "(<NSEntityDescription: 0xf6947b0>) name Log, managedObjectClassName Log, renamingIdentifier Log, isAbstract 0, superentity name (null), properties {\n    date = \"(<NSAttributeDescription: 0xf6941d0>), name date, isOptional 1, isTransient 0, entity Log, renamingIdentifier date, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null)\";\n    medicine = \"(<NSRelationshipDescription: 0xf694410>), name medicine, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\";\n    note = \"(<NSAttributeDescription: 0xf694220>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities (null), userInfo {\n}, versionHashModifier (null)";
Medicine = "(<NSEntityDescription: 0xf694810>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\n    active = \"(<NSAttributeDescription: 0xf694270>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\";\n    dose = \"(<NSAttributeDescription: 0xf6942c0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n    hoursBetween = \"(<NSAttributeDescription: 0xf694310>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\";\n    logs = \"(<NSRelationshipDescription: 0xf694470>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\";\n    name = \"(<NSAttributeDescription: 0xf694360>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n    \\\"com.apple.syncservices.Syncable\\\" = NO;\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities (null), userInfo {\n    \"com.apple.syncservices.Syncable\" = NO;\n}, versionHashModifier (null)"; }, fetch request templates { }, sourceModel=(<NSManagedObjectModel: 0x2adbb0>) isEditable 1, entities {
Log = "(<NSEntityDescription: 0x2ac700>) name Log, managedObjectClassName Log, renamingIdentifier Log, isAbstract 0, superentity name (null), properties {\n    date = \"(<NSAttributeDescription: 0x294ac0>), name date, isOptional 1, isTransient 0, entity Log, renamingIdentifier date, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null)\";\n    medicine = \"(<NSRelationshipDescription: 0x294a60>), name medicine, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\";\n    note = \"(<NSAttributeDescription: 0x2ac810>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities {\n}, userInfo {\n}, versionHashModifier (null)";
Medicine = "(<NSEntityDescription: 0x294b10>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\n    active = \"(<NSAttributeDescription: 0x2adaa0>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\";\n    dose = \"(<NSAttributeDescription: 0x2adaf0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\";\n    hoursBetween = \"(<NSAttributeDescription: 0x2adb40>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\";\n    logs = \"(<NSRelationshipDescription: 0x2ada40>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\";\n    name = \"(<NSAttributeDescription: 0x2ad9f0>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\n), warnings (\\n), versionHashModifier (null)\\n userInfo {\\n    \\\"com.apple.syncservices.Syncable\\\" = NO;\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\";\n}, subentities {\n}, userInfo {\n    \"com.apple.syncservices.Syncable\" = NO;\n}, versionHashModifier (null)"; }, fetch request templates { }, NSUnderlyingError=0x2b0140 "The operation couldn’t be completed. (Cocoa error 134190.)"}, {
NSUnderlyingError = "Error Domain=NSCocoaErrorDomain Code=134190 \"The operation couldn\U2019t be completed. (Cocoa error 134190.)\" UserInfo=0x2b0160 {reason=Source and destination attribute types are incompatible, entity=Medicine, property=dose}";
destinationModel = "(<NSManagedObjectModel: 0xf694e20>) isEditable 0, entities {\n    Log = \"(<NSEntityDescription: 0xf6947b0>) name Log, managedObjectClassName Log, renamingIdentifier Log, isAbstract 0, superentity name (null), properties {\\n    date = \\\"(<NSAttributeDescription: 0xf6941d0>), name date, isOptional 1, isTransient 0, entity Log, renamingIdentifier date, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null)\\\";\\n    medicine = \\\"(<NSRelationshipDescription: 0xf694410>), name medicine, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\\\";\\n    note = \\\"(<NSAttributeDescription: 0xf694220>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities (null), userInfo {\\n}, versionHashModifier (null)\";\n    Medicine = \"(<NSEntityDescription: 0xf694810>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\\n    active = \\\"(<NSAttributeDescription: 0xf694270>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\\\";\\n    dose = \\\"(<NSAttributeDescription: 0xf6942c0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n    hoursBetween = \\\"(<NSAttributeDescription: 0xf694310>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\\\";\\n    logs = \\\"(<NSRelationshipDescription: 0xf694470>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\\\";\\n    name = \\\"(<NSAttributeDescription: 0xf694360>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n    \\\\\\\"com.apple.syncservices.Syncable\\\\\\\" = NO;\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities (null), userInfo {\\n    \\\"com.apple.syncservices.Syncable\\\" = NO;\\n}, versionHashModifier (null)\";\n}, fetch request templates {\n}";
reason = "Can't find or automatically infer mapping model for migration";
sourceModel = "(<NSManagedObjectModel: 0x2adbb0>) isEditable 1, entities {\n    Log = \"(<NSEntityDescription: 0x2ac700>) name Log, managedObjectClassName Log, renamingIdentifier Log, isAbstract 0, superentity name (null), properties {\\n    date = \\\"(<NSAttributeDescription: 0x294ac0>), name date, isOptional 1, isTransient 0, entity Log, renamingIdentifier date, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 900 , attributeValueClassName NSDate, defaultValue (null)\\\";\\n    medicine = \\\"(<NSRelationshipDescription: 0x294a60>), name medicine, isOptional 1, isTransient 0, entity Log, renamingIdentifier medicine, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Medicine, inverseRelationship logs, minCount 1, maxCount 1, isOrdered 0, deleteRule 1\\\";\\n    note = \\\"(<NSAttributeDescription: 0x2ac810>), name note, isOptional 1, isTransient 0, entity Log, renamingIdentifier note, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities {\\n}, userInfo {\\n}, versionHashModifier (null)\";\n    Medicine = \"(<NSEntityDescription: 0x294b10>) name Medicine, managedObjectClassName Medicine, renamingIdentifier Medicine, isAbstract 0, superentity name (null), properties {\\n    active = \\\"(<NSAttributeDescription: 0x2adaa0>), name active, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier active, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 800 , attributeValueClassName NSNumber, defaultValue (null)\\\";\\n    dose = \\\"(<NSAttributeDescription: 0x2adaf0>), name dose, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier amountToTake, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\\\";\\n    hoursBetween = \\\"(<NSAttributeDescription: 0x2adb40>), name hoursBetween, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier hoursBetween, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, attributeType 100 , attributeValueClassName NSNumber, defaultValue 0\\\";\\n    logs = \\\"(<NSRelationshipDescription: 0x2ada40>), name logs, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier logs, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n}, destination entity Log, inverseRelationship medicine, minCount 0, maxCount 0, isOrdered 0, deleteRule 1\\\";\\n    name = \\\"(<NSAttributeDescription: 0x2ad9f0>), name name, isOptional 1, isTransient 0, entity Medicine, renamingIdentifier name, validation predicates (\\\\n), warnings (\\\\n), versionHashModifier (null)\\\\n userInfo {\\\\n    \\\\\\\"com.apple.syncservices.Syncable\\\\\\\" = NO;\\\\n}, attributeType 700 , attributeValueClassName NSString, defaultValue (null)\\\";\\n}, subentities {\\n}, userInfo {\\n    \\\"com.apple.syncservices.Syncable\\\" = NO;\\n}, versionHashModifier (null)\";\n}, fetch request templates {\n}"; }
4

3 に答える 3

10

関連する属性に特定の名前と型があることを示す新しいスキーマとともに、既存の SQL またはその他の永続ストアを Core Data に渡します。Core Data がストアを確認すると、ストアが現在のスキーマに対して正しい形式ではないことがわかります。これにより、表示されているエラーがスローされます。

アプリをまだリリースしていない場合は、現在のストレージを削除して (iOS の場合はアプリを削除して)、もう一度起動してください。すべてがうまくいくはずです。

実際に移行を実行する必要がある場合 (たとえば、古いスキーマが既にデプロイされている場合) は、明らかに移行について考える必要があります。

スキムスルーに基づいて、これは良い情報のように見えます。

最終的にプロジェクト内に両方のバージョンのスキーマが存在し、それらの間でマッピングするのに十分な情報を Core Data に提供します。フィールドの名前変更について話しているだけの場合は、スキーマだけでそれを実現できます (プロパティが選択され、クリックしたときに、Xcode の右側のユーティリティ ペインの [バージョン管理] の下にある [名前の変更 ID] フィールドを確認してください)。右端のタブにあるデータモデルインスペクターを表示します)が、それがタイプを強制できるかどうかはわかりません。それができない場合は、Xcode で編集できるもう 1 つのグラフィカルなものであるマッピング モデルが追加されます。これは間違いなく強制できます。

于 2012-07-10T22:11:15.437 に答える