MigrationError

Not available in Objective-C.
Swift
public enum MigrationError: Error

extension MigrationError: CustomStringConvertible

Errors that can occur preventing persistent store loading, passed into the callback given to PersistentContainer.loadPersistentStores(...)-[PersistentContainer loadPersistentStoresWithCompletionHandler:] or PersistentCloudKitContainer.loadPersistentStores(...)-[PersistentCloudKitContainer loadPersistentStoresWithCompletionHandler:].

When any of these unusual conditions occurs, the persistent container provides a lot of human-readable (-ish) information to the logging interface. The first step to debugging one of these errors is to read that text and try to make sense of it.


Topics

Cases

case coreqMigrationFailed(NSPersistentStoreDescription)

The persistent store has not been loaded because another store associated with the persistent container required migration but there was an error attempting to migrate it. To avoid leaving the app’s stores with a mixture of versions this store load has been abandoned.

Declaration
Swift
case coreqMigrationFailed(NSPersistentStoreDescription)

case badModelVersionOrder(NSPersistentStoreDescription, ModelVersionOrder)

Migration cannot precede because the ModelVersionOrder for the store is invalid. This could mean:

  • .patternMatchCompare – not a valid regular expression (according to NSRegularExpressionNSRegularExpression);
  • .list – empty list, or list contains repeated elements;
  • .pairList – there is a cycle in the list of migrations.
Declaration
Swift
case badModelVersionOrder(NSPersistentStoreDescription, ModelVersionOrder)

case cannotFindSourceModel(NSPersistentStoreDescription, [String : Any])

Migration cannot proceed because the persistent container cannot find a managed object model that is compatible with the persistent store’s metadata in the bundles passed to PersistentContainer.init(...) or PersistentCloudKitContainer.init(...). The enum parameters are the particular store with the problem and the metadata of that store that cannot be matched to a model.

Declaration
Swift
case cannotFindSourceModel(NSPersistentStoreDescription, [String: Any])

case cannotFindDestinationModel(NSPersistentStoreDescription, NSManagedObjectModel)

Migration cannot proceed because the persistent container cannot find an object model that matches the NSManagedObjectModelNSManagedObjectModel passed to PersistentContainer.init(...) or PersistentCloudKitContainer.init(...) in the list of bundles. This means either a bundle is missing from the list or the NSManagedObjectModelNSManagedObjectModel has been created by merging several models – this second use case is not currently supported by the library. Sorry.

Declaration
Swift
case cannotFindDestinationModel(
    NSPersistentStoreDescription, NSManagedObjectModel)

case noRouteBetweenModels(String, String)

Migration cannot proceed because the persistent container cannot find a migration path from the source model version (first string parameter) to the destination model version (second string parameter) using mapping models from the bundles passed to PersistentContainer.init(...) or PersistentCloudKitContainer.init(...) combined with inferred mappings if enabled. Possible reasons include:

Declaration
Swift
case noRouteBetweenModels(String, String)

case cyclicRoute1(String, String)

Migration cannot proceed because the persistent container is confused: after examining all the model versions and mapping models it has not been able to understand the fastest way of migrating between the two model versions named in the string parameters. This probably means there are cycles in the persistent container’s ModelVersionOrder.

Declaration
Swift
case cyclicRoute1(String, String)

case cyclicRoute2(String, String)

Migration cannot proceed because the persistent container is confused: after examining all the model versions and mapping models it has not been able to understand the fastest way of migrating between the two model versions named in the string parameters. This also probably means there are cycles in the persistent container’s ModelVersionOrder.

Declaration
Swift
case cyclicRoute2(String, String)

case cyclicRoute3(String, String)

Migration cannot proceed because the persistent container is confused: after examining all the model versions and mapping models it has found a path involving a mapping model that leads from the store’s current model version back to itself. This ALSO probably means there are cycles in the persistent container’s ModelVersionOrder.

Declaration
Swift
case cyclicRoute3(String, String)

case logicFailure(String)

Migration has failed due to what seems to be a bug in the library code or, less likely, its dependencies. Sorry about that. A bug report including as full a log output as possible would be welcome. The string parameter is a brief explanation of the problem.

Declaration
Swift
case logicFailure(String)

Properties

var description: String

A human-readable description of the error.

Declaration
Swift
public var description: String { get }