{"action":"created","comment":{"url":"https://api.github.com/repos/tj/node-migrate/pulls/comments/65799581","id":65799581,"diff_hunk":"@@ -11,8 +11,34 @@\n \n module.exports = Migration;\n \n+var isGeneratorFn = require('is-generator').fn;\n+\n+var co;\n+try {\n+  co = require('co');\n+} catch (err) {\n+  // ignore\n+}\n+\n function Migration(title, up, down) {\n   this.title = title;\n-  this.up = up;\n-  this.down = down;\n-}\n\\ No newline at end of file\n+  this.up = migrationFunction(up);\n+  this.down = migrationFunction(down);\n+}\n+\n+function migrationFunction(originalFn) {\n+  var fn = originalFn;\n+\n+  if (isGeneratorFn(originalFn)) {\n+    if (!co) {\n+      throw new Error(\"Generator migrations can only be used if the 'co' library is included. \" +\n+        \"Run 'npm install --save co' to use generator migrations.\");\n+    }\n+\n+    fn = function (next) {\n+      return co(originalFn).then(next.bind(null, null), next);","path":"lib/migration.js","position":33,"original_position":33,"commit_id":"f68047e7f75a9b5066593d9755a4762c9b318f75","original_commit_id":"f68047e7f75a9b5066593d9755a4762c9b318f75","user":{"login":"LinusU","id":189580,"avatar_url":"https://avatars.githubusercontent.com/u/189580?v=3","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"body":"btw. this is swallowing any errors that could potentially occur in `next`. The correct way to callbackify a promise is like so:\r\n\r\n```js\r\nco(originalFn).then(function () {\r\n  setImmediate(next, null)\r\n}, function (err) {\r\n  setImmediate(next, err)\r\n})\r\n```","created_at":"2016-06-04T08:28:23Z","updated_at":"2016-06-04T08:28:23Z","html_url":"https://github.com/tj/node-migrate/pull/64#discussion_r65799581","pull_request_url":"https://api.github.com/repos/tj/node-migrate/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/tj/node-migrate/pulls/comments/65799581"},"html":{"href":"https://github.com/tj/node-migrate/pull/64#discussion_r65799581"},"pull_request":{"href":"https://api.github.com/repos/tj/node-migrate/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/tj/node-migrate/pulls/64","id":72591691,"html_url":"https://github.com/tj/node-migrate/pull/64","diff_url":"https://github.com/tj/node-migrate/pull/64.diff","patch_url":"https://github.com/tj/node-migrate/pull/64.patch","issue_url":"https://api.github.com/repos/tj/node-migrate/issues/64","number":64,"state":"open","locked":false,"title":"Support generator functions as up/down functions in migrations","user":{"login":"diosmosis","id":125140,"avatar_url":"https://avatars.githubusercontent.com/u/125140?v=3","gravatar_id":"","url":"https://api.github.com/users/diosmosis","html_url":"https://github.com/diosmosis","followers_url":"https://api.github.com/users/diosmosis/followers","following_url":"https://api.github.com/users/diosmosis/following{/other_user}","gists_url":"https://api.github.com/users/diosmosis/gists{/gist_id}","starred_url":"https://api.github.com/users/diosmosis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diosmosis/subscriptions","organizations_url":"https://api.github.com/users/diosmosis/orgs","repos_url":"https://api.github.com/users/diosmosis/repos","events_url":"https://api.github.com/users/diosmosis/events{/privacy}","received_events_url":"https://api.github.com/users/diosmosis/received_events","type":"User","site_admin":false},"body":"This PR lets you create migrations w/ generator functions, like so:\r\n\r\n```\r\nexports.up = function* () {\r\n    // ... yield lots of good stuff ...\r\n};\r\n\r\nexports.down = function* () {\r\n    // ... yield even more good stuff ...\r\n};\r\n```\r\n\r\nGenerator functions are only wrapped if the `'co'` module is available (so users don't have to include 'co' if they don't want to).\r\n\r\nTests are included.","created_at":"2016-06-04T03:34:05Z","updated_at":"2016-06-04T08:28:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b23c594bb7d397aa4f6e9e2734d8b7e516c1544c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tj/node-migrate/pulls/64/commits","review_comments_url":"https://api.github.com/repos/tj/node-migrate/pulls/64/comments","review_comment_url":"https://api.github.com/repos/tj/node-migrate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tj/node-migrate/issues/64/comments","statuses_url":"https://api.github.com/repos/tj/node-migrate/statuses/f68047e7f75a9b5066593d9755a4762c9b318f75","head":{"label":"diosmosis:generators","ref":"generators","sha":"f68047e7f75a9b5066593d9755a4762c9b318f75","user":{"login":"diosmosis","id":125140,"avatar_url":"https://avatars.githubusercontent.com/u/125140?v=3","gravatar_id":"","url":"https://api.github.com/users/diosmosis","html_url":"https://github.com/diosmosis","followers_url":"https://api.github.com/users/diosmosis/followers","following_url":"https://api.github.com/users/diosmosis/following{/other_user}","gists_url":"https://api.github.com/users/diosmosis/gists{/gist_id}","starred_url":"https://api.github.com/users/diosmosis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diosmosis/subscriptions","organizations_url":"https://api.github.com/users/diosmosis/orgs","repos_url":"https://api.github.com/users/diosmosis/repos","events_url":"https://api.github.com/users/diosmosis/events{/privacy}","received_events_url":"https://api.github.com/users/diosmosis/received_events","type":"User","site_admin":false},"repo":{"id":60389084,"name":"node-migrate","full_name":"diosmosis/node-migrate","owner":{"login":"diosmosis","id":125140,"avatar_url":"https://avatars.githubusercontent.com/u/125140?v=3","gravatar_id":"","url":"https://api.github.com/users/diosmosis","html_url":"https://github.com/diosmosis","followers_url":"https://api.github.com/users/diosmosis/followers","following_url":"https://api.github.com/users/diosmosis/following{/other_user}","gists_url":"https://api.github.com/users/diosmosis/gists{/gist_id}","starred_url":"https://api.github.com/users/diosmosis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diosmosis/subscriptions","organizations_url":"https://api.github.com/users/diosmosis/orgs","repos_url":"https://api.github.com/users/diosmosis/repos","events_url":"https://api.github.com/users/diosmosis/events{/privacy}","received_events_url":"https://api.github.com/users/diosmosis/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/diosmosis/node-migrate","description":"Abstract migration framework for node","fork":true,"url":"https://api.github.com/repos/diosmosis/node-migrate","forks_url":"https://api.github.com/repos/diosmosis/node-migrate/forks","keys_url":"https://api.github.com/repos/diosmosis/node-migrate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/diosmosis/node-migrate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/diosmosis/node-migrate/teams","hooks_url":"https://api.github.com/repos/diosmosis/node-migrate/hooks","issue_events_url":"https://api.github.com/repos/diosmosis/node-migrate/issues/events{/number}","events_url":"https://api.github.com/repos/diosmosis/node-migrate/events","assignees_url":"https://api.github.com/repos/diosmosis/node-migrate/assignees{/user}","branches_url":"https://api.github.com/repos/diosmosis/node-migrate/branches{/branch}","tags_url":"https://api.github.com/repos/diosmosis/node-migrate/tags","blobs_url":"https://api.github.com/repos/diosmosis/node-migrate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/diosmosis/node-migrate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/diosmosis/node-migrate/git/refs{/sha}","trees_url":"https://api.github.com/repos/diosmosis/node-migrate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/diosmosis/node-migrate/statuses/{sha}","languages_url":"https://api.github.com/repos/diosmosis/node-migrate/languages","stargazers_url":"https://api.github.com/repos/diosmosis/node-migrate/stargazers","contributors_url":"https://api.github.com/repos/diosmosis/node-migrate/contributors","subscribers_url":"https://api.github.com/repos/diosmosis/node-migrate/subscribers","subscription_url":"https://api.github.com/repos/diosmosis/node-migrate/subscription","commits_url":"https://api.github.com/repos/diosmosis/node-migrate/commits{/sha}","git_commits_url":"https://api.github.com/repos/diosmosis/node-migrate/git/commits{/sha}","comments_url":"https://api.github.com/repos/diosmosis/node-migrate/comments{/number}","issue_comment_url":"https://api.github.com/repos/diosmosis/node-migrate/issues/comments{/number}","contents_url":"https://api.github.com/repos/diosmosis/node-migrate/contents/{+path}","compare_url":"https://api.github.com/repos/diosmosis/node-migrate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/diosmosis/node-migrate/merges","archive_url":"https://api.github.com/repos/diosmosis/node-migrate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/diosmosis/node-migrate/downloads","issues_url":"https://api.github.com/repos/diosmosis/node-migrate/issues{/number}","pulls_url":"https://api.github.com/repos/diosmosis/node-migrate/pulls{/number}","milestones_url":"https://api.github.com/repos/diosmosis/node-migrate/milestones{/number}","notifications_url":"https://api.github.com/repos/diosmosis/node-migrate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/diosmosis/node-migrate/labels{/name}","releases_url":"https://api.github.com/repos/diosmosis/node-migrate/releases{/id}","deployments_url":"https://api.github.com/repos/diosmosis/node-migrate/deployments","created_at":"2016-06-04T02:23:29Z","updated_at":"2016-06-04T02:23:30Z","pushed_at":"2016-06-04T03:29:42Z","git_url":"git://github.com/diosmosis/node-migrate.git","ssh_url":"git@github.com:diosmosis/node-migrate.git","clone_url":"https://github.com/diosmosis/node-migrate.git","svn_url":"https://github.com/diosmosis/node-migrate","homepage":"","size":82,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tj:master","ref":"master","sha":"0b1090becf4c97f82deba8f92914782b1d95000f","user":{"login":"tj","id":25254,"avatar_url":"https://avatars.githubusercontent.com/u/25254?v=3","gravatar_id":"","url":"https://api.github.com/users/tj","html_url":"https://github.com/tj","followers_url":"https://api.github.com/users/tj/followers","following_url":"https://api.github.com/users/tj/following{/other_user}","gists_url":"https://api.github.com/users/tj/gists{/gist_id}","starred_url":"https://api.github.com/users/tj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tj/subscriptions","organizations_url":"https://api.github.com/users/tj/orgs","repos_url":"https://api.github.com/users/tj/repos","events_url":"https://api.github.com/users/tj/events{/privacy}","received_events_url":"https://api.github.com/users/tj/received_events","type":"User","site_admin":false},"repo":{"id":1657729,"name":"node-migrate","full_name":"tj/node-migrate","owner":{"login":"tj","id":25254,"avatar_url":"https://avatars.githubusercontent.com/u/25254?v=3","gravatar_id":"","url":"https://api.github.com/users/tj","html_url":"https://github.com/tj","followers_url":"https://api.github.com/users/tj/followers","following_url":"https://api.github.com/users/tj/following{/other_user}","gists_url":"https://api.github.com/users/tj/gists{/gist_id}","starred_url":"https://api.github.com/users/tj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tj/subscriptions","organizations_url":"https://api.github.com/users/tj/orgs","repos_url":"https://api.github.com/users/tj/repos","events_url":"https://api.github.com/users/tj/events{/privacy}","received_events_url":"https://api.github.com/users/tj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tj/node-migrate","description":"Abstract migration framework for node","fork":false,"url":"https://api.github.com/repos/tj/node-migrate","forks_url":"https://api.github.com/repos/tj/node-migrate/forks","keys_url":"https://api.github.com/repos/tj/node-migrate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tj/node-migrate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tj/node-migrate/teams","hooks_url":"https://api.github.com/repos/tj/node-migrate/hooks","issue_events_url":"https://api.github.com/repos/tj/node-migrate/issues/events{/number}","events_url":"https://api.github.com/repos/tj/node-migrate/events","assignees_url":"https://api.github.com/repos/tj/node-migrate/assignees{/user}","branches_url":"https://api.github.com/repos/tj/node-migrate/branches{/branch}","tags_url":"https://api.github.com/repos/tj/node-migrate/tags","blobs_url":"https://api.github.com/repos/tj/node-migrate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tj/node-migrate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tj/node-migrate/git/refs{/sha}","trees_url":"https://api.github.com/repos/tj/node-migrate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tj/node-migrate/statuses/{sha}","languages_url":"https://api.github.com/repos/tj/node-migrate/languages","stargazers_url":"https://api.github.com/repos/tj/node-migrate/stargazers","contributors_url":"https://api.github.com/repos/tj/node-migrate/contributors","subscribers_url":"https://api.github.com/repos/tj/node-migrate/subscribers","subscription_url":"https://api.github.com/repos/tj/node-migrate/subscription","commits_url":"https://api.github.com/repos/tj/node-migrate/commits{/sha}","git_commits_url":"https://api.github.com/repos/tj/node-migrate/git/commits{/sha}","comments_url":"https://api.github.com/repos/tj/node-migrate/comments{/number}","issue_comment_url":"https://api.github.com/repos/tj/node-migrate/issues/comments{/number}","contents_url":"https://api.github.com/repos/tj/node-migrate/contents/{+path}","compare_url":"https://api.github.com/repos/tj/node-migrate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tj/node-migrate/merges","archive_url":"https://api.github.com/repos/tj/node-migrate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tj/node-migrate/downloads","issues_url":"https://api.github.com/repos/tj/node-migrate/issues{/number}","pulls_url":"https://api.github.com/repos/tj/node-migrate/pulls{/number}","milestones_url":"https://api.github.com/repos/tj/node-migrate/milestones{/number}","notifications_url":"https://api.github.com/repos/tj/node-migrate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tj/node-migrate/labels{/name}","releases_url":"https://api.github.com/repos/tj/node-migrate/releases{/id}","deployments_url":"https://api.github.com/repos/tj/node-migrate/deployments","created_at":"2011-04-24T21:00:22Z","updated_at":"2016-06-02T12:27:14Z","pushed_at":"2016-06-04T03:34:05Z","git_url":"git://github.com/tj/node-migrate.git","ssh_url":"git@github.com:tj/node-migrate.git","clone_url":"https://github.com/tj/node-migrate.git","svn_url":"https://github.com/tj/node-migrate","homepage":"","size":119,"stargazers_count":596,"watchers_count":596,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":123,"mirror_url":null,"open_issues_count":14,"forks":123,"open_issues":14,"watchers":596,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tj/node-migrate/pulls/64"},"html":{"href":"https://github.com/tj/node-migrate/pull/64"},"issue":{"href":"https://api.github.com/repos/tj/node-migrate/issues/64"},"comments":{"href":"https://api.github.com/repos/tj/node-migrate/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/tj/node-migrate/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/tj/node-migrate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tj/node-migrate/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/tj/node-migrate/statuses/f68047e7f75a9b5066593d9755a4762c9b318f75"}}}}
{"actor":{"display_login":"LinusU"}}