{"action":"created","comment":{"url":"https://api.github.com/repos/realm/realm-cocoa/pulls/comments/23196451","id":23196451,"diff_hunk":"@@ -18,31 +18,111 @@\n \n import Realm\n \n+/// A block that is used to migrate objects from one version of a Realm to a newer version.\n public typealias MigrationBlock = (migration: Migration, oldSchemaVersion: UInt) -> Void\n \n+/**\n+Specify a schema version and an associated migration block which is applied when\n+opening any Realm with an old schema version.\n+\n+Before you can open an existing `Realm` which has a different on-disk schema\n+from the schema defined in your object interfaces you must provide a migration\n+block which converts from the disk schema to your current object schema. At the\n+minimum your migration block must initialize any properties which were added to\n+existing objects without defaults and ensure uniqueness if a primary key\n+property is added to an existing object.\n+\n+You should call this method before accessing any `Realm` instances which\n+require migration. After registering your migration block Realm will call your\n+block automatically as needed.\n+\n+:warning: Unsuccessful migrations will throw exceptions when the migration block\n+          is applied. This will happen in the following cases:\n+- The migration block was run and returns a schema version which is not higher\n+  than the previous schema version.\n+- A new property without a default was added to an object and not initialized\n+  during the migration. You are required to either supply a default value or to\n+  manually populate added properties during a migration.\n+\n+:param: schemaVersion  The current schema version.\n+:param: migrationBlock The block which migrates the Realm to the current version.\n+*/\n public func setSchemaVersion(schemaVersion: UInt, migrationBlock: MigrationBlock) {\n     RLMRealm.setSchemaVersion(schemaVersion, withMigrationBlock: {\n         migrationBlock(migration: Migration($0), oldSchemaVersion: $1)\n     })\n }\n \n+/**\n+Performs the registered migration block on the Realm at the given path.\n+\n+This method is called automatically when opening a Realm for the first time and does\n+not need to be called explicitly. You can choose to call this method to control\n+exactly when and how migrations are performed.\n+\n+:see: setSchemaVersion(_:_:)\n+\n+:param: realmPath The path of the Realm to migrate.\n+\n+:returns: The error that occurred while applying the migration if any.\n+*/\n public func migrateRealm(path: String) -> NSError? {\n     return RLMRealm.migrateRealmAtPath(path)\n }\n \n+/**\n+Migration encapsulates the information passed into a MigrationBlock when updating the schema version of a Realm instance.\n+*/\n public class Migration {\n+    // MARK: Properties\n+\n+    /// The old schema.\n+    /// This is the schema that describes the Realm before the migration is applied.","path":"Realm/RealmSwift/Migration.swift","position":63,"original_position":63,"commit_id":"f35f8e051c94733e9456a467d5f1765b77395074","original_commit_id":"f35f8e051c94733e9456a467d5f1765b77395074","user":{"login":"jpsim","id":474794,"avatar_url":"https://avatars.githubusercontent.com/u/474794?v=3","gravatar_id":"","url":"https://api.github.com/users/jpsim","html_url":"https://github.com/jpsim","followers_url":"https://api.github.com/users/jpsim/followers","following_url":"https://api.github.com/users/jpsim/following{/other_user}","gists_url":"https://api.github.com/users/jpsim/gists{/gist_id}","starred_url":"https://api.github.com/users/jpsim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpsim/subscriptions","organizations_url":"https://api.github.com/users/jpsim/orgs","repos_url":"https://api.github.com/users/jpsim/repos","events_url":"https://api.github.com/users/jpsim/events{/privacy}","received_events_url":"https://api.github.com/users/jpsim/received_events","type":"User","site_admin":false},"body":"Remove the first line here. Total comment could just read `The schema that describes the Realm before the migration is applied.`. Same for the new schema one.","created_at":"2015-01-20T00:38:10Z","updated_at":"2015-01-20T00:38:10Z","html_url":"https://github.com/realm/realm-cocoa/pull/1356#discussion_r23196451","pull_request_url":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356","_links":{"self":{"href":"https://api.github.com/repos/realm/realm-cocoa/pulls/comments/23196451"},"html":{"href":"https://github.com/realm/realm-cocoa/pull/1356#discussion_r23196451"},"pull_request":{"href":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356"}}},"pull_request":{"url":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356","id":27549017,"html_url":"https://github.com/realm/realm-cocoa/pull/1356","diff_url":"https://github.com/realm/realm-cocoa/pull/1356.diff","patch_url":"https://github.com/realm/realm-cocoa/pull/1356.patch","issue_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1356","number":1356,"state":"open","locked":false,"title":"[Documentation] Document the swift interface","user":{"login":"segiddins","id":1946610,"avatar_url":"https://avatars.githubusercontent.com/u/1946610?v=3","gravatar_id":"","url":"https://api.github.com/users/segiddins","html_url":"https://github.com/segiddins","followers_url":"https://api.github.com/users/segiddins/followers","following_url":"https://api.github.com/users/segiddins/following{/other_user}","gists_url":"https://api.github.com/users/segiddins/gists{/gist_id}","starred_url":"https://api.github.com/users/segiddins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segiddins/subscriptions","organizations_url":"https://api.github.com/users/segiddins/orgs","repos_url":"https://api.github.com/users/segiddins/repos","events_url":"https://api.github.com/users/segiddins/events{/privacy}","received_events_url":"https://api.github.com/users/segiddins/received_events","type":"User","site_admin":false},"body":"Connected to #1238.\r\n\r\n\\c @alazier @jpsim ","created_at":"2015-01-17T01:16:55Z","updated_at":"2015-01-20T00:38:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ca6c2f2ed13e2ab6019dcb888c80d41c7b4e1ab3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356/commits","review_comments_url":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356/comments","review_comment_url":"https://api.github.com/repos/realm/realm-cocoa/pulls/comments/{number}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/issues/1356/comments","statuses_url":"https://api.github.com/repos/realm/realm-cocoa/statuses/f35f8e051c94733e9456a467d5f1765b77395074","head":{"label":"realm:seg-swift-docs","ref":"seg-swift-docs","sha":"f35f8e051c94733e9456a467d5f1765b77395074","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":4044891,"name":"realm-cocoa","full_name":"realm/realm-cocoa","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/realm-cocoa","description":"Realm is a mobile database: a replacement for Core Data & SQLite","fork":false,"url":"https://api.github.com/repos/realm/realm-cocoa","forks_url":"https://api.github.com/repos/realm/realm-cocoa/forks","keys_url":"https://api.github.com/repos/realm/realm-cocoa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/realm-cocoa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/realm-cocoa/teams","hooks_url":"https://api.github.com/repos/realm/realm-cocoa/hooks","issue_events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/events{/number}","events_url":"https://api.github.com/repos/realm/realm-cocoa/events","assignees_url":"https://api.github.com/repos/realm/realm-cocoa/assignees{/user}","branches_url":"https://api.github.com/repos/realm/realm-cocoa/branches{/branch}","tags_url":"https://api.github.com/repos/realm/realm-cocoa/tags","blobs_url":"https://api.github.com/repos/realm/realm-cocoa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/realm-cocoa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/realm-cocoa/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/realm-cocoa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/realm-cocoa/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/realm-cocoa/languages","stargazers_url":"https://api.github.com/repos/realm/realm-cocoa/stargazers","contributors_url":"https://api.github.com/repos/realm/realm-cocoa/contributors","subscribers_url":"https://api.github.com/repos/realm/realm-cocoa/subscribers","subscription_url":"https://api.github.com/repos/realm/realm-cocoa/subscription","commits_url":"https://api.github.com/repos/realm/realm-cocoa/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/realm-cocoa/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/realm-cocoa/issues/comments/{number}","contents_url":"https://api.github.com/repos/realm/realm-cocoa/contents/{+path}","compare_url":"https://api.github.com/repos/realm/realm-cocoa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/realm-cocoa/merges","archive_url":"https://api.github.com/repos/realm/realm-cocoa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/realm-cocoa/downloads","issues_url":"https://api.github.com/repos/realm/realm-cocoa/issues{/number}","pulls_url":"https://api.github.com/repos/realm/realm-cocoa/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/realm-cocoa/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/realm-cocoa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/realm-cocoa/labels{/name}","releases_url":"https://api.github.com/repos/realm/realm-cocoa/releases{/id}","created_at":"2012-04-16T20:06:56Z","updated_at":"2015-01-19T21:13:01Z","pushed_at":"2015-01-20T00:19:16Z","git_url":"git://github.com/realm/realm-cocoa.git","ssh_url":"git@github.com:realm/realm-cocoa.git","clone_url":"https://github.com/realm/realm-cocoa.git","svn_url":"https://github.com/realm/realm-cocoa","homepage":"http://realm.io","size":106091,"stargazers_count":2799,"watchers_count":2799,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":205,"mirror_url":null,"open_issues_count":80,"forks":205,"open_issues":80,"watchers":2799,"default_branch":"master"}},"base":{"label":"realm:al-swift","ref":"al-swift","sha":"141caf9366879c66d2a2625e8fa9783551eb1f47","user":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"repo":{"id":4044891,"name":"realm-cocoa","full_name":"realm/realm-cocoa","owner":{"login":"realm","id":7575099,"avatar_url":"https://avatars.githubusercontent.com/u/7575099?v=3","gravatar_id":"","url":"https://api.github.com/users/realm","html_url":"https://github.com/realm","followers_url":"https://api.github.com/users/realm/followers","following_url":"https://api.github.com/users/realm/following{/other_user}","gists_url":"https://api.github.com/users/realm/gists{/gist_id}","starred_url":"https://api.github.com/users/realm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/realm/subscriptions","organizations_url":"https://api.github.com/users/realm/orgs","repos_url":"https://api.github.com/users/realm/repos","events_url":"https://api.github.com/users/realm/events{/privacy}","received_events_url":"https://api.github.com/users/realm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/realm/realm-cocoa","description":"Realm is a mobile database: a replacement for Core Data & SQLite","fork":false,"url":"https://api.github.com/repos/realm/realm-cocoa","forks_url":"https://api.github.com/repos/realm/realm-cocoa/forks","keys_url":"https://api.github.com/repos/realm/realm-cocoa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/realm/realm-cocoa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/realm/realm-cocoa/teams","hooks_url":"https://api.github.com/repos/realm/realm-cocoa/hooks","issue_events_url":"https://api.github.com/repos/realm/realm-cocoa/issues/events{/number}","events_url":"https://api.github.com/repos/realm/realm-cocoa/events","assignees_url":"https://api.github.com/repos/realm/realm-cocoa/assignees{/user}","branches_url":"https://api.github.com/repos/realm/realm-cocoa/branches{/branch}","tags_url":"https://api.github.com/repos/realm/realm-cocoa/tags","blobs_url":"https://api.github.com/repos/realm/realm-cocoa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/realm/realm-cocoa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/realm/realm-cocoa/git/refs{/sha}","trees_url":"https://api.github.com/repos/realm/realm-cocoa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/realm/realm-cocoa/statuses/{sha}","languages_url":"https://api.github.com/repos/realm/realm-cocoa/languages","stargazers_url":"https://api.github.com/repos/realm/realm-cocoa/stargazers","contributors_url":"https://api.github.com/repos/realm/realm-cocoa/contributors","subscribers_url":"https://api.github.com/repos/realm/realm-cocoa/subscribers","subscription_url":"https://api.github.com/repos/realm/realm-cocoa/subscription","commits_url":"https://api.github.com/repos/realm/realm-cocoa/commits{/sha}","git_commits_url":"https://api.github.com/repos/realm/realm-cocoa/git/commits{/sha}","comments_url":"https://api.github.com/repos/realm/realm-cocoa/comments{/number}","issue_comment_url":"https://api.github.com/repos/realm/realm-cocoa/issues/comments/{number}","contents_url":"https://api.github.com/repos/realm/realm-cocoa/contents/{+path}","compare_url":"https://api.github.com/repos/realm/realm-cocoa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/realm/realm-cocoa/merges","archive_url":"https://api.github.com/repos/realm/realm-cocoa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/realm/realm-cocoa/downloads","issues_url":"https://api.github.com/repos/realm/realm-cocoa/issues{/number}","pulls_url":"https://api.github.com/repos/realm/realm-cocoa/pulls{/number}","milestones_url":"https://api.github.com/repos/realm/realm-cocoa/milestones{/number}","notifications_url":"https://api.github.com/repos/realm/realm-cocoa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/realm/realm-cocoa/labels{/name}","releases_url":"https://api.github.com/repos/realm/realm-cocoa/releases{/id}","created_at":"2012-04-16T20:06:56Z","updated_at":"2015-01-19T21:13:01Z","pushed_at":"2015-01-20T00:19:16Z","git_url":"git://github.com/realm/realm-cocoa.git","ssh_url":"git@github.com:realm/realm-cocoa.git","clone_url":"https://github.com/realm/realm-cocoa.git","svn_url":"https://github.com/realm/realm-cocoa","homepage":"http://realm.io","size":106091,"stargazers_count":2799,"watchers_count":2799,"language":"Objective-C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":205,"mirror_url":null,"open_issues_count":80,"forks":205,"open_issues":80,"watchers":2799,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356"},"html":{"href":"https://github.com/realm/realm-cocoa/pull/1356"},"issue":{"href":"https://api.github.com/repos/realm/realm-cocoa/issues/1356"},"comments":{"href":"https://api.github.com/repos/realm/realm-cocoa/issues/1356/comments"},"review_comments":{"href":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356/comments"},"review_comment":{"href":"https://api.github.com/repos/realm/realm-cocoa/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/realm/realm-cocoa/pulls/1356/commits"},"statuses":{"href":"https://api.github.com/repos/realm/realm-cocoa/statuses/f35f8e051c94733e9456a467d5f1765b77395074"}}}}