ModelVersionOrder
public enum ModelVersionOrder: Sendable
extension ModelVersionOrder: CustomStringConvertible
A rule for ordering model versions. The persistent container performs automatic multi-step migration in the direction defined by this rule, which operates on the names of the model version. Note that the model version here is the part of its filename before ‘.xcdatamodel’ – not the optional ‘Model Version Identifier’ that you can set in the model’s properties panel.
Topics
Cases
case compare
case compare
Compare the model versions directly, but interpreting numbers like a human – using
the NSString.CompareOptions.numeric
NSString.CompareOptions.numeric
algorithm, meaning that for example MyModel_v2
precedes MyModel_v10
and MyModel_A
precedes MyModel_B
.
Declaration
case compare
case patternMatchCompare(String)
case patternMatchCompare(String)
case regexMatchCompare(NSRegularExpression)
case regexMatchCompare(NSRegularExpression)
Match each model version against a compiled regular expression. Then compare either the
entire match or, if it exists, the first capture group, using the compare
algorithm.
Declaration
case regexMatchCompare(NSRegularExpression)
case list([String])
case list([String])
Explicitly list all the model versions in order. The first element in the array is the the earliest version and the last is the latest version. Model versions not in the list are not considered for migration.
Declaration
case list([String])
case pairList([(String, String)])
case pairList([(String, String)])
Explicitly list the entire set of migration pairs that are permitted. This can be seen as
a stricter form of .list
in that .list(A, B, C)
will permit A->C but .pairList((A,B), (B,C))
will not allow A->C in a single migration step. The library checks for cycles in the described
migrations.
Declaration
case perStore(@Sendable (NSPersistentStoreDescription) -> ModelVersionOrder)
case perStore(@Sendable (NSPersistentStoreDescription) -> ModelVersionOrder)
Use a different order for different stores under the same container.
Declaration
case perStore(@Sendable (NSPersistentStoreDescription) -> ModelVersionOrder)
Properties
var description: String
var description: String