# MigrationChain

    public struct MigrationChain : ExpressibleByNilLiteral, ExpressibleByStringLiteral, ExpressibleByDictionaryLiteral, ExpressibleByArrayLiteral, Equatable

A `MigrationChain` indicates the sequence of model versions to be used as the order for progressive migrations. This is typically passed to the `SchemaHistory` or the `DataStack` initializer and will be applied to all stores added to the `DataStack` with `addStorage(...)` and its variants.

Initializing with empty values (either `nil`, `[]`, or `[:]`) instructs the `DataStack` to use the .xcdatamodel’s current version as the final version, and to disable progressive migrations:

    let dataStack = DataStack(migrationChain: nil)

This means that the mapping model will be computed from the store’s version straight to the `DataStack`‘s model version. To support progressive migrations, specify the linear order of versions:

    let dataStack = DataStack(migrationChain:
       ["MyAppModel", "MyAppModelV2", "MyAppModelV3", "MyAppModelV4"])

or for more complex migration paths, a version tree that maps the key-values to the source-destination versions:

    let dataStack = DataStack(migrationChain: [
        "MyAppModel": "MyAppModelV3",
        "MyAppModelV2": "MyAppModelV4",
        "MyAppModelV3": "MyAppModelV4"
    ])

This allows for different migration paths depending on the starting version. The example above resolves to the following paths:

- MyAppModel-MyAppModelV3-MyAppModelV4
- MyAppModelV2-MyAppModelV4
- MyAppModelV3-MyAppModelV4

The `MigrationChain` is validated when passed to the `DataStack` and unless it is empty, will raise an assertion if any of the following conditions are met:

- a version appears twice in an array
- a version appears twice as a key in a dictionary literal
- a loop is found in any of the paths

- `init()`

  Initializes the `MigrationChain` with empty values, which instructs the `DataStack` to use the .xcdatamodel’s current version as the final version, and to disable progressive migrations.

  #### Declaration

  Swift

      public init()

- `init(_:)`

  Initializes the `MigrationChain` with a single model version, which instructs the `DataStack` to use the the specified version as the final version, and to disable progressive migrations.

  #### Declaration

  Swift

      public init(_ value: String)

- `init(_:)`

  Initializes the `MigrationChain` with a linear order of versions, which becomes the order of the `DataStack`‘s progressive migrations.

  #### Declaration

  Swift

      public init<T>(_ elements: T) where T : Collection, T.Element == String

- `init(_:)`

  Initializes the `MigrationChain` with a version tree, which becomes the order of the `DataStack`‘s progressive migrations.

  #### Declaration

  Swift

      public init(_ elements: [(String, String)])

- `init(_:)`

  Initializes the `MigrationChain` with a version tree, which becomes the order of the `DataStack`‘s progressive migrations.

  #### Declaration

  Swift

      public init(_ dictionary: [String : String])

### ExpressibleByNilLiteral

- `init(nilLiteral:)`

  #### Declaration

  Swift

      public init(nilLiteral: ())

### ExpressibleByStringLiteral

- `init(stringLiteral:)`

  #### Declaration

  Swift

      public init(stringLiteral value: String)

### ExtendedGraphemeClusterLiteralConvertible

- `init(extendedGraphemeClusterLiteral:)`

  #### Declaration

  Swift

      public init(extendedGraphemeClusterLiteral value: String)

### UnicodeScalarLiteralConvertible

- `init(unicodeScalarLiteral:)`

  #### Declaration

  Swift

      public init(unicodeScalarLiteral value: String)

### ExpressibleByDictionaryLiteral

- `init(dictionaryLiteral:)`

  #### Declaration

  Swift

      public init(dictionaryLiteral elements: (String, String)...)

### ExpressibleByArrayLiteral

- `init(arrayLiteral:)`

  #### Declaration

  Swift

      public init(arrayLiteral elements: String...)

### Equatable

- `==(_:_:)`

  #### Declaration

  Swift

      public static func == (lhs: MigrationChain, rhs: MigrationChain) -> Bool

### CustomDebugStringConvertible

- `debugDescription`

  #### Declaration

  Swift

      public var debugDescription: String { get }