Migration
public final class 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.
-
Declaration
Swift
public var oldSchema: Schema { return Schema(rlmMigration.oldSchema) } -
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
objectClassNameThe name of the
Objectclass to enumerate.blockThe block providing both the old and new versions of an object in this Realm.
-
Declaration
Swift
public func create(className: String, value: AnyObject = [:]) -> MigrationObjectParameters
classNameThe name of the
Objectclass to create.valueThe object used to populate the new
Object. This can be any key/value coding compliant object, or a JSON object such as those returned from the methods inNSJSONSerialization, 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.
-
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) -> BoolParameters
objectClassNameThe name of the Object class to delete.
Return Value
trueif there was any data to delete.
View on GitHub
Install in Dash
Migration Class Reference