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 theRealmbefore applying a migration.Declaration
Swift
public var oldSchema: Schema { return Schema(rlmMigration.oldSchema) } -
The migration’s new
Schema, describing theRealmafter 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)Parameters
classNameThe name of the
Objectclass to enumerate.blockThe block providing both the old and new versions of an object in this Realm.
-
Create an
Objectof typeclassNamein the Realm being migrated.Declaration
Swift
public func create(className: String, value: AnyObject = [:]) -> MigrationObjectParameters
classNameThe name of the
Objectclass to create.objectThe object used to populate the object. This can be any key/value coding compliant object, or a JSON object such as those returned from the methods in
NSJSONSerialization, or anArraywith one object for each persisted property. An exception will be thrown if any required properties are not present and no default is set.Return Value
The created object.
-
Delete an object from a Realm during a migration. This can be called within
enumerate(_:block:).Declaration
Swift
public func delete(object: MigrationObject)Parameters
objectObject to be deleted from the Realm being migrated.
View on GitHub
Install in Dash
Migration Class Reference