{"action":"created","comment":{"url":"https://api.github.com/repos/medic/medic-analytics/pulls/comments/66310422","id":66310422,"diff_hunk":"@@ -18,30 +19,48 @@ var startTime = function() {\n   });\n };\n \n+var potentiallyMigrateDatabase = function() {\n+  return new Promise(function (resolve, reject) {\n+    postgrator.setConfig({\n+      migrationDirectory: __dirname + '/migrations',\n+      driver: 'pg',\n+      connectionString: process.env.POSTGRESQL_URL\n+    });\n+\n+    postgrator.migrate('201505271423', function(err, migrations) {\n+      if (err) {\n+        reject(err);\n+      } else {\n+        postgrator.endConnection(function() {\n+          resolve(migrations);\n+        });\n+      }\n+    });\n+  });\n+};\n+\n var loop = function () {\n   var starttime;\n   startTime()\n     .then(function (time) {\n       starttime = time;\n     })\n-\n+    .then(potentiallyMigrateDatabase)\n+    .then(function(migrations) {\n+      console.log('Sucessfully migrated', migrations);\n+    })\n     .then(couch2pg)\n     .then(function () {\n       console.log('Imported successfully at ' + Date());\n-    }, function (err) {\n-      console.log('Import errored at ' + Date());\n-      console.log(err);\n     })\n-\n     .then(xmlforms)\n     .then(function () {\n       console.log('XML forms completed at ' + Date());\n-    }, function (err) {\n-      console.log('XML forms errored at ' + Date());\n-      console.log(err);\n     })\n-\n-    .then(function () {\n+    .catch(function(err) {\n+      console.error(err);","path":"index.js","position":null,"original_position":64,"commit_id":"67f85cbffbce8e604137b6c8db985803940e1bce","original_commit_id":"7005707491f2338b35685cb001599f8831d0a914","user":{"login":"btbonval","id":880439,"avatar_url":"https://avatars.githubusercontent.com/u/880439?v=3","gravatar_id":"","url":"https://api.github.com/users/btbonval","html_url":"https://github.com/btbonval","followers_url":"https://api.github.com/users/btbonval/followers","following_url":"https://api.github.com/users/btbonval/following{/other_user}","gists_url":"https://api.github.com/users/btbonval/gists{/gist_id}","starred_url":"https://api.github.com/users/btbonval/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btbonval/subscriptions","organizations_url":"https://api.github.com/users/btbonval/orgs","repos_url":"https://api.github.com/users/btbonval/repos","events_url":"https://api.github.com/users/btbonval/events{/privacy}","received_events_url":"https://api.github.com/users/btbonval/received_events","type":"User","site_admin":false},"body":"Originally, errors thrown by couch2pg did not prevent xmlforms from running. It is true that xmlforms consumes couch2pg, but in practice, I have seen occasions where couch2pg produces more data than xmlforms can consume in an interval. In cases like that, it made sense to continue running xmlforms parsing even when couch2pg failed. Perhaps this no longer holds with the changes to couch2pg.\r\n\r\nWe should definitely throw a timestamp on here regardless.","created_at":"2016-06-08T18:19:43Z","updated_at":"2016-06-08T18:19:43Z","html_url":"https://github.com/medic/medic-analytics/pull/30#discussion_r66310422","pull_request_url":"https://api.github.com/repos/medic/medic-analytics/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/medic/medic-analytics/pulls/comments/66310422"},"html":{"href":"https://github.com/medic/medic-analytics/pull/30#discussion_r66310422"},"pull_request":{"href":"https://api.github.com/repos/medic/medic-analytics/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/medic/medic-analytics/pulls/30","id":72944088,"html_url":"https://github.com/medic/medic-analytics/pull/30","diff_url":"https://github.com/medic/medic-analytics/pull/30.diff","patch_url":"https://github.com/medic/medic-analytics/pull/30.patch","issue_url":"https://api.github.com/repos/medic/medic-analytics/issues/30","number":30,"state":"open","locked":false,"title":"medic/medic-webapp#2124 Reflect edited and deleted documents from couchdb","user":{"login":"SCdF","id":583851,"avatar_url":"https://avatars.githubusercontent.com/u/583851?v=3","gravatar_id":"","url":"https://api.github.com/users/SCdF","html_url":"https://github.com/SCdF","followers_url":"https://api.github.com/users/SCdF/followers","following_url":"https://api.github.com/users/SCdF/following{/other_user}","gists_url":"https://api.github.com/users/SCdF/gists{/gist_id}","starred_url":"https://api.github.com/users/SCdF/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SCdF/subscriptions","organizations_url":"https://api.github.com/users/SCdF/orgs","repos_url":"https://api.github.com/users/SCdF/repos","events_url":"https://api.github.com/users/SCdF/events{/privacy}","received_events_url":"https://api.github.com/users/SCdF/received_events","type":"User","site_admin":false},"body":"Adds DB migration support and teaches couch2pg to understand edits and deletes.","created_at":"2016-06-07T20:38:10Z","updated_at":"2016-06-08T18:19:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b0da9ce000feebf3545d86699c3d03a54f37e12d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/medic/medic-analytics/pulls/30/commits","review_comments_url":"https://api.github.com/repos/medic/medic-analytics/pulls/30/comments","review_comment_url":"https://api.github.com/repos/medic/medic-analytics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/medic/medic-analytics/issues/30/comments","statuses_url":"https://api.github.com/repos/medic/medic-analytics/statuses/67f85cbffbce8e604137b6c8db985803940e1bce","head":{"label":"medic:2124.reflect-edited-and-deleted-rebased","ref":"2124.reflect-edited-and-deleted-rebased","sha":"67f85cbffbce8e604137b6c8db985803940e1bce","user":{"login":"medic","id":474424,"avatar_url":"https://avatars.githubusercontent.com/u/474424?v=3","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"repo":{"id":38839516,"name":"medic-analytics","full_name":"medic/medic-analytics","owner":{"login":"medic","id":474424,"avatar_url":"https://avatars.githubusercontent.com/u/474424?v=3","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/medic/medic-analytics","description":"Software for creating read-only replicas of Medic Mobile data, using PostgreSQL v9.4","fork":false,"url":"https://api.github.com/repos/medic/medic-analytics","forks_url":"https://api.github.com/repos/medic/medic-analytics/forks","keys_url":"https://api.github.com/repos/medic/medic-analytics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/medic/medic-analytics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/medic/medic-analytics/teams","hooks_url":"https://api.github.com/repos/medic/medic-analytics/hooks","issue_events_url":"https://api.github.com/repos/medic/medic-analytics/issues/events{/number}","events_url":"https://api.github.com/repos/medic/medic-analytics/events","assignees_url":"https://api.github.com/repos/medic/medic-analytics/assignees{/user}","branches_url":"https://api.github.com/repos/medic/medic-analytics/branches{/branch}","tags_url":"https://api.github.com/repos/medic/medic-analytics/tags","blobs_url":"https://api.github.com/repos/medic/medic-analytics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/medic/medic-analytics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/medic/medic-analytics/git/refs{/sha}","trees_url":"https://api.github.com/repos/medic/medic-analytics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/medic/medic-analytics/statuses/{sha}","languages_url":"https://api.github.com/repos/medic/medic-analytics/languages","stargazers_url":"https://api.github.com/repos/medic/medic-analytics/stargazers","contributors_url":"https://api.github.com/repos/medic/medic-analytics/contributors","subscribers_url":"https://api.github.com/repos/medic/medic-analytics/subscribers","subscription_url":"https://api.github.com/repos/medic/medic-analytics/subscription","commits_url":"https://api.github.com/repos/medic/medic-analytics/commits{/sha}","git_commits_url":"https://api.github.com/repos/medic/medic-analytics/git/commits{/sha}","comments_url":"https://api.github.com/repos/medic/medic-analytics/comments{/number}","issue_comment_url":"https://api.github.com/repos/medic/medic-analytics/issues/comments{/number}","contents_url":"https://api.github.com/repos/medic/medic-analytics/contents/{+path}","compare_url":"https://api.github.com/repos/medic/medic-analytics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/medic/medic-analytics/merges","archive_url":"https://api.github.com/repos/medic/medic-analytics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/medic/medic-analytics/downloads","issues_url":"https://api.github.com/repos/medic/medic-analytics/issues{/number}","pulls_url":"https://api.github.com/repos/medic/medic-analytics/pulls{/number}","milestones_url":"https://api.github.com/repos/medic/medic-analytics/milestones{/number}","notifications_url":"https://api.github.com/repos/medic/medic-analytics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/medic/medic-analytics/labels{/name}","releases_url":"https://api.github.com/repos/medic/medic-analytics/releases{/id}","deployments_url":"https://api.github.com/repos/medic/medic-analytics/deployments","created_at":"2015-07-09T19:00:16Z","updated_at":"2016-01-28T20:23:55Z","pushed_at":"2016-06-07T20:38:10Z","git_url":"git://github.com/medic/medic-analytics.git","ssh_url":"git@github.com:medic/medic-analytics.git","clone_url":"https://github.com/medic/medic-analytics.git","svn_url":"https://github.com/medic/medic-analytics","homepage":null,"size":185,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"base":{"label":"medic:master","ref":"master","sha":"bee4857cfbbbfa761b4e52aace77d535c88c331f","user":{"login":"medic","id":474424,"avatar_url":"https://avatars.githubusercontent.com/u/474424?v=3","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"repo":{"id":38839516,"name":"medic-analytics","full_name":"medic/medic-analytics","owner":{"login":"medic","id":474424,"avatar_url":"https://avatars.githubusercontent.com/u/474424?v=3","gravatar_id":"","url":"https://api.github.com/users/medic","html_url":"https://github.com/medic","followers_url":"https://api.github.com/users/medic/followers","following_url":"https://api.github.com/users/medic/following{/other_user}","gists_url":"https://api.github.com/users/medic/gists{/gist_id}","starred_url":"https://api.github.com/users/medic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medic/subscriptions","organizations_url":"https://api.github.com/users/medic/orgs","repos_url":"https://api.github.com/users/medic/repos","events_url":"https://api.github.com/users/medic/events{/privacy}","received_events_url":"https://api.github.com/users/medic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/medic/medic-analytics","description":"Software for creating read-only replicas of Medic Mobile data, using PostgreSQL v9.4","fork":false,"url":"https://api.github.com/repos/medic/medic-analytics","forks_url":"https://api.github.com/repos/medic/medic-analytics/forks","keys_url":"https://api.github.com/repos/medic/medic-analytics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/medic/medic-analytics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/medic/medic-analytics/teams","hooks_url":"https://api.github.com/repos/medic/medic-analytics/hooks","issue_events_url":"https://api.github.com/repos/medic/medic-analytics/issues/events{/number}","events_url":"https://api.github.com/repos/medic/medic-analytics/events","assignees_url":"https://api.github.com/repos/medic/medic-analytics/assignees{/user}","branches_url":"https://api.github.com/repos/medic/medic-analytics/branches{/branch}","tags_url":"https://api.github.com/repos/medic/medic-analytics/tags","blobs_url":"https://api.github.com/repos/medic/medic-analytics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/medic/medic-analytics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/medic/medic-analytics/git/refs{/sha}","trees_url":"https://api.github.com/repos/medic/medic-analytics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/medic/medic-analytics/statuses/{sha}","languages_url":"https://api.github.com/repos/medic/medic-analytics/languages","stargazers_url":"https://api.github.com/repos/medic/medic-analytics/stargazers","contributors_url":"https://api.github.com/repos/medic/medic-analytics/contributors","subscribers_url":"https://api.github.com/repos/medic/medic-analytics/subscribers","subscription_url":"https://api.github.com/repos/medic/medic-analytics/subscription","commits_url":"https://api.github.com/repos/medic/medic-analytics/commits{/sha}","git_commits_url":"https://api.github.com/repos/medic/medic-analytics/git/commits{/sha}","comments_url":"https://api.github.com/repos/medic/medic-analytics/comments{/number}","issue_comment_url":"https://api.github.com/repos/medic/medic-analytics/issues/comments{/number}","contents_url":"https://api.github.com/repos/medic/medic-analytics/contents/{+path}","compare_url":"https://api.github.com/repos/medic/medic-analytics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/medic/medic-analytics/merges","archive_url":"https://api.github.com/repos/medic/medic-analytics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/medic/medic-analytics/downloads","issues_url":"https://api.github.com/repos/medic/medic-analytics/issues{/number}","pulls_url":"https://api.github.com/repos/medic/medic-analytics/pulls{/number}","milestones_url":"https://api.github.com/repos/medic/medic-analytics/milestones{/number}","notifications_url":"https://api.github.com/repos/medic/medic-analytics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/medic/medic-analytics/labels{/name}","releases_url":"https://api.github.com/repos/medic/medic-analytics/releases{/id}","deployments_url":"https://api.github.com/repos/medic/medic-analytics/deployments","created_at":"2015-07-09T19:00:16Z","updated_at":"2016-01-28T20:23:55Z","pushed_at":"2016-06-07T20:38:10Z","git_url":"git://github.com/medic/medic-analytics.git","ssh_url":"git@github.com:medic/medic-analytics.git","clone_url":"https://github.com/medic/medic-analytics.git","svn_url":"https://github.com/medic/medic-analytics","homepage":null,"size":185,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/medic/medic-analytics/pulls/30"},"html":{"href":"https://github.com/medic/medic-analytics/pull/30"},"issue":{"href":"https://api.github.com/repos/medic/medic-analytics/issues/30"},"comments":{"href":"https://api.github.com/repos/medic/medic-analytics/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/medic/medic-analytics/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/medic/medic-analytics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/medic/medic-analytics/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/medic/medic-analytics/statuses/67f85cbffbce8e604137b6c8db985803940e1bce"}}}}
{"actor":{"display_login":"btbonval"}}