Skip to content

Commit

Permalink
[Migration] Document the new migrateRealm function
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Aug 11, 2015
1 parent 7c7583d commit aaec762
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
19 changes: 17 additions & 2 deletions RealmSwift-swift1.2/Migration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ public func migrateRealm(path: String, encryptionKey: NSData? = nil) -> NSError?
return migrateRealm(configuration: configuration)
}

/**
Performs the configuration's migration block on the Realm created by the given
configuration.

This method is called automatically when opening a Realm for the first time and does
not need to be called explicitly. You can choose to call this method to control
exactly when and how migrations are performed.

:param: configuration The RealmConfiguration used to create the Realm to be
migrated, and containing the schema version and migration
block used to perform the migration.

:returns: `nil` if the migration was successful, or an `NSError` object that describes the problem
that occured otherwise.
*/
public func migrateRealm(configuration: RealmConfiguration = RealmConfiguration.defaultConfiguration) -> NSError? {
return RLMRealm.migrateRealm(configuration.rlmConfiguration)
}
Expand Down Expand Up @@ -165,7 +180,7 @@ public final class Migration {
/**
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.

:param: className The name of the `Object` class to enumerate.
:param: block The block providing both the old and new versions of an object in this Realm.
*/
Expand All @@ -184,7 +199,7 @@ public final class Migration {
`NSJSONSerialization`, or an `Array` with one object for each persisted
property. An exception will be thrown if any required properties are not
present and no default is set.

:returns: The created object.
*/
public func create(className: String, value: AnyObject = [:]) -> MigrationObject {
Expand Down
15 changes: 15 additions & 0 deletions RealmSwift-swift2.0/Migration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ public func migrateRealm(path: String, encryptionKey: NSData? = nil) -> NSError?
return migrateRealm(configuration)
}

/**
Performs the configuration's migration block on the Realm created by the given
configuration.

This method is called automatically when opening a Realm for the first time and does
not need to be called explicitly. You can choose to call this method to control
exactly when and how migrations are performed.

- parameter configuration: The RealmConfiguration used to create the Realm to be
migrated, and containing the schema version and migration
block used to perform the migration.

- returns: `nil` if the migration was successful, or an `NSError` object that describes the problem
that occured otherwise.
*/
public func migrateRealm(configuration: RealmConfiguration = RealmConfiguration.defaultConfiguration) -> NSError? {
return RLMRealm.migrateRealm(configuration.rlmConfiguration)
}
Expand Down

0 comments on commit aaec762

Please sign in to comment.