我的旧ManagedObject模型如下所示,具有约束:[trackURL
]
@objc(TrackDownloadInfo)
public class TrackDownloadInfo: NSManagedObject {
@NSManaged public var trackURL: String
@NSManaged public var downloadState: Int16
@NSManaged public var id: Int64
@NSManaged public var type: Int16
}
我刚刚更改了约束: [{id
,type
],而没有任何模型版本,这会导致迁移错误:
Error Domain = NSCocoaErrorDomain代码= 134110“在持久存储迁移期间发生错误。 UserInfo = {sourceURL = file:///var/mobile/Containers/Data/Application/FA440C2E-63EF-4533-94EB-4EA721A645A9/Library/Application%20Support/MyApp.sqlite,原因=无法迁移就地存储:约束尝试迁移期间发生冲突,destinationURL = file:///var/mobile/Containers/Data/Application/FA440C2E-63EF-4533-94EB-4EA721A645A9/Library/Application%20Support/MyApp.sqlite,NSUnderlyingError = 0x2816da820 {Error Domain = NSCocoaErrorDomain Code = 134111“(null)” UserInfo = {_ NSCoreDataOptimisticLockingFailureConflictsKey =(“”),NSUnderlyingException =约束违规,原因=尝试迁移期间的约束违规,NSExceptionOmitCallstacks = true}}},[“ NSUnderlyingError”:错误域= NSCocoaErrorDomain代码= 134111 “(null)” UserInfo = {_ NSCoreDataOptimisticLockingFailureConflictsKey =(“”),NSUnderlyingException =约束违反,原因=约束v
我知道这是由于表中存在重复的条目,它们具有相同的id
和type
,但trackURL
不同。
我想删除两个条目以进行迁移。我没有任何办法做到这一点。