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 Schema
s 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
className
The name of the
Object
class to enumerate.block
The block providing both the old and new versions of an object in this Realm.
-
Declaration
Swift
public func create(className: String, value: AnyObject = [:]) -> MigrationObject
Parameters
className
The name of the
Object
class to create.object
The 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 anArray
with 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
object
Object 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) -> Bool
Parameters
name
The name of the Object class to delete.
Return Value
whether there was any data to delete.