Migration

Migration is the object passed into a user-defined MigrationBlock when updating the version of a Realm instance.

This object provides access to the previous and current Schemas for this migration.

  • The migration’s old Schema, describing the Realm before applying a migration.

    Declaration

    Swift

    public var oldSchema: Schema { return Schema(rlmMigration.oldSchema) }
  • The migration’s new Schema, describing the Realm after applying a migration.

    Declaration

    Swift

    public var newSchema: Schema { return Schema(rlmMigration.newSchema) }
  • Enumerates objects of a given type in this Realm, providing both the old and new versions of each object. Object properties can be accessed using subscripting.

    Declaration

    Swift

    public func enumerate(objectClassName: String, _ block: MigrationObjectEnumerateBlock)
  • Create an Object of type className in the Realm being migrated.

    Declaration

    Swift

    public func create(className: String, value: AnyObject = [:]) -> MigrationObject
  • Delete an object from a Realm during a migration. This can be called within enumerate(_:block:).

    Declaration

    Swift

    public func delete(object: MigrationObject)
  • Deletes the data for the class with the given name. This deletes all objects of the given class, and if the Object subclass no longer exists in your program, cleans up any remaining metadata for the class in the Realm file.

    Declaration

    Swift

    public func deleteData(objectClassName: String) -> Bool