{"action":"created","comment":{"url":"https://api.github.com/repos/tgriesser/knex/pulls/comments/46246973","id":46246973,"diff_hunk":"@@ -105,9 +107,25 @@ export default class Migrator {\n   // dependent on the migration config settings.\n   _ensureTable() {\n     var table = this.config.tableName;\n+    var lockTable = this._getLockTableName(table);\n     return this.knex.schema.hasTable(table)\n       .then((exists) => {\n         if (!exists) return this._createMigrationTable(table);\n+      })\n+      .then(() => {\n+        return this.knex.schema.hasTable(lockTable)\n+          .then((exists) => {","path":"src/migrate/index.js","position":20,"original_position":20,"commit_id":"cce1159ac0128d5ee7fdd53222e4d16701bb1465","original_commit_id":"cce1159ac0128d5ee7fdd53222e4d16701bb1465","user":{"login":"elhigu","id":696345,"avatar_url":"https://avatars.githubusercontent.com/u/696345?v=3","gravatar_id":"","url":"https://api.github.com/users/elhigu","html_url":"https://github.com/elhigu","followers_url":"https://api.github.com/users/elhigu/followers","following_url":"https://api.github.com/users/elhigu/following{/other_user}","gists_url":"https://api.github.com/users/elhigu/gists{/gist_id}","starred_url":"https://api.github.com/users/elhigu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elhigu/subscriptions","organizations_url":"https://api.github.com/users/elhigu/orgs","repos_url":"https://api.github.com/users/elhigu/repos","events_url":"https://api.github.com/users/elhigu/events{/privacy}","received_events_url":"https://api.github.com/users/elhigu/received_events","type":"User","site_admin":false},"body":"Also... there might be multiple is_locked rows added if multiple processes are racing to run migrations for the first time, but it probably is not a problem, since only the first row is used :)","created_at":"2015-12-01T07:27:57Z","updated_at":"2015-12-01T07:27:57Z","html_url":"https://github.com/tgriesser/knex/pull/1067#discussion_r46246973","pull_request_url":"https://api.github.com/repos/tgriesser/knex/pulls/1067","_links":{"self":{"href":"https://api.github.com/repos/tgriesser/knex/pulls/comments/46246973"},"html":{"href":"https://github.com/tgriesser/knex/pull/1067#discussion_r46246973"},"pull_request":{"href":"https://api.github.com/repos/tgriesser/knex/pulls/1067"}}},"pull_request":{"url":"https://api.github.com/repos/tgriesser/knex/pulls/1067","id":51411254,"html_url":"https://github.com/tgriesser/knex/pull/1067","diff_url":"https://github.com/tgriesser/knex/pull/1067.diff","patch_url":"https://github.com/tgriesser/knex/pull/1067.patch","issue_url":"https://api.github.com/repos/tgriesser/knex/issues/1067","number":1067,"state":"open","locked":false,"title":"Add migration locking","user":{"login":"dustinmartin","id":141065,"avatar_url":"https://avatars.githubusercontent.com/u/141065?v=3","gravatar_id":"","url":"https://api.github.com/users/dustinmartin","html_url":"https://github.com/dustinmartin","followers_url":"https://api.github.com/users/dustinmartin/followers","following_url":"https://api.github.com/users/dustinmartin/following{/other_user}","gists_url":"https://api.github.com/users/dustinmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinmartin/subscriptions","organizations_url":"https://api.github.com/users/dustinmartin/orgs","repos_url":"https://api.github.com/users/dustinmartin/repos","events_url":"https://api.github.com/users/dustinmartin/events{/privacy}","received_events_url":"https://api.github.com/users/dustinmartin/received_events","type":"User","site_admin":false},"body":"Add migration locking so multiple services cannot try to run migrations at same time. This added a new lock table. If migrations are locked and migrations are run by another service it results in an error.","created_at":"2015-11-20T21:35:24Z","updated_at":"2015-12-01T07:27:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fd8a5c1bd025ea14103b6bdaea118296cee5795","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tgriesser/knex/pulls/1067/commits","review_comments_url":"https://api.github.com/repos/tgriesser/knex/pulls/1067/comments","review_comment_url":"https://api.github.com/repos/tgriesser/knex/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/1067/comments","statuses_url":"https://api.github.com/repos/tgriesser/knex/statuses/cce1159ac0128d5ee7fdd53222e4d16701bb1465","head":{"label":"dustinmartin:migration-lock","ref":"migration-lock","sha":"cce1159ac0128d5ee7fdd53222e4d16701bb1465","user":{"login":"dustinmartin","id":141065,"avatar_url":"https://avatars.githubusercontent.com/u/141065?v=3","gravatar_id":"","url":"https://api.github.com/users/dustinmartin","html_url":"https://github.com/dustinmartin","followers_url":"https://api.github.com/users/dustinmartin/followers","following_url":"https://api.github.com/users/dustinmartin/following{/other_user}","gists_url":"https://api.github.com/users/dustinmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinmartin/subscriptions","organizations_url":"https://api.github.com/users/dustinmartin/orgs","repos_url":"https://api.github.com/users/dustinmartin/repos","events_url":"https://api.github.com/users/dustinmartin/events{/privacy}","received_events_url":"https://api.github.com/users/dustinmartin/received_events","type":"User","site_admin":false},"repo":{"id":46139501,"name":"knex","full_name":"dustinmartin/knex","owner":{"login":"dustinmartin","id":141065,"avatar_url":"https://avatars.githubusercontent.com/u/141065?v=3","gravatar_id":"","url":"https://api.github.com/users/dustinmartin","html_url":"https://github.com/dustinmartin","followers_url":"https://api.github.com/users/dustinmartin/followers","following_url":"https://api.github.com/users/dustinmartin/following{/other_user}","gists_url":"https://api.github.com/users/dustinmartin/gists{/gist_id}","starred_url":"https://api.github.com/users/dustinmartin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dustinmartin/subscriptions","organizations_url":"https://api.github.com/users/dustinmartin/orgs","repos_url":"https://api.github.com/users/dustinmartin/repos","events_url":"https://api.github.com/users/dustinmartin/events{/privacy}","received_events_url":"https://api.github.com/users/dustinmartin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dustinmartin/knex","description":"A query builder for PostgreSQL, MySQL and SQLite3, designed to be flexible, portable, and fun to use.","fork":true,"url":"https://api.github.com/repos/dustinmartin/knex","forks_url":"https://api.github.com/repos/dustinmartin/knex/forks","keys_url":"https://api.github.com/repos/dustinmartin/knex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dustinmartin/knex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dustinmartin/knex/teams","hooks_url":"https://api.github.com/repos/dustinmartin/knex/hooks","issue_events_url":"https://api.github.com/repos/dustinmartin/knex/issues/events{/number}","events_url":"https://api.github.com/repos/dustinmartin/knex/events","assignees_url":"https://api.github.com/repos/dustinmartin/knex/assignees{/user}","branches_url":"https://api.github.com/repos/dustinmartin/knex/branches{/branch}","tags_url":"https://api.github.com/repos/dustinmartin/knex/tags","blobs_url":"https://api.github.com/repos/dustinmartin/knex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dustinmartin/knex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dustinmartin/knex/git/refs{/sha}","trees_url":"https://api.github.com/repos/dustinmartin/knex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dustinmartin/knex/statuses/{sha}","languages_url":"https://api.github.com/repos/dustinmartin/knex/languages","stargazers_url":"https://api.github.com/repos/dustinmartin/knex/stargazers","contributors_url":"https://api.github.com/repos/dustinmartin/knex/contributors","subscribers_url":"https://api.github.com/repos/dustinmartin/knex/subscribers","subscription_url":"https://api.github.com/repos/dustinmartin/knex/subscription","commits_url":"https://api.github.com/repos/dustinmartin/knex/commits{/sha}","git_commits_url":"https://api.github.com/repos/dustinmartin/knex/git/commits{/sha}","comments_url":"https://api.github.com/repos/dustinmartin/knex/comments{/number}","issue_comment_url":"https://api.github.com/repos/dustinmartin/knex/issues/comments{/number}","contents_url":"https://api.github.com/repos/dustinmartin/knex/contents/{+path}","compare_url":"https://api.github.com/repos/dustinmartin/knex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dustinmartin/knex/merges","archive_url":"https://api.github.com/repos/dustinmartin/knex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dustinmartin/knex/downloads","issues_url":"https://api.github.com/repos/dustinmartin/knex/issues{/number}","pulls_url":"https://api.github.com/repos/dustinmartin/knex/pulls{/number}","milestones_url":"https://api.github.com/repos/dustinmartin/knex/milestones{/number}","notifications_url":"https://api.github.com/repos/dustinmartin/knex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dustinmartin/knex/labels{/name}","releases_url":"https://api.github.com/repos/dustinmartin/knex/releases{/id}","created_at":"2015-11-13T18:23:07Z","updated_at":"2015-11-13T18:23:09Z","pushed_at":"2015-11-30T23:32:55Z","git_url":"git://github.com/dustinmartin/knex.git","ssh_url":"git@github.com:dustinmartin/knex.git","clone_url":"https://github.com/dustinmartin/knex.git","svn_url":"https://github.com/dustinmartin/knex","homepage":"knexjs.org","size":5560,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tgriesser:master","ref":"master","sha":"51ef27bd4fcb538abaa8ecfd001d1d1659aa398f","user":{"login":"tgriesser","id":154748,"avatar_url":"https://avatars.githubusercontent.com/u/154748?v=3","gravatar_id":"","url":"https://api.github.com/users/tgriesser","html_url":"https://github.com/tgriesser","followers_url":"https://api.github.com/users/tgriesser/followers","following_url":"https://api.github.com/users/tgriesser/following{/other_user}","gists_url":"https://api.github.com/users/tgriesser/gists{/gist_id}","starred_url":"https://api.github.com/users/tgriesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgriesser/subscriptions","organizations_url":"https://api.github.com/users/tgriesser/orgs","repos_url":"https://api.github.com/users/tgriesser/repos","events_url":"https://api.github.com/users/tgriesser/events{/privacy}","received_events_url":"https://api.github.com/users/tgriesser/received_events","type":"User","site_admin":false},"repo":{"id":7363211,"name":"knex","full_name":"tgriesser/knex","owner":{"login":"tgriesser","id":154748,"avatar_url":"https://avatars.githubusercontent.com/u/154748?v=3","gravatar_id":"","url":"https://api.github.com/users/tgriesser","html_url":"https://github.com/tgriesser","followers_url":"https://api.github.com/users/tgriesser/followers","following_url":"https://api.github.com/users/tgriesser/following{/other_user}","gists_url":"https://api.github.com/users/tgriesser/gists{/gist_id}","starred_url":"https://api.github.com/users/tgriesser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tgriesser/subscriptions","organizations_url":"https://api.github.com/users/tgriesser/orgs","repos_url":"https://api.github.com/users/tgriesser/repos","events_url":"https://api.github.com/users/tgriesser/events{/privacy}","received_events_url":"https://api.github.com/users/tgriesser/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tgriesser/knex","description":"A query builder for PostgreSQL, MySQL and SQLite3, designed to be flexible, portable, and fun to use.","fork":false,"url":"https://api.github.com/repos/tgriesser/knex","forks_url":"https://api.github.com/repos/tgriesser/knex/forks","keys_url":"https://api.github.com/repos/tgriesser/knex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tgriesser/knex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tgriesser/knex/teams","hooks_url":"https://api.github.com/repos/tgriesser/knex/hooks","issue_events_url":"https://api.github.com/repos/tgriesser/knex/issues/events{/number}","events_url":"https://api.github.com/repos/tgriesser/knex/events","assignees_url":"https://api.github.com/repos/tgriesser/knex/assignees{/user}","branches_url":"https://api.github.com/repos/tgriesser/knex/branches{/branch}","tags_url":"https://api.github.com/repos/tgriesser/knex/tags","blobs_url":"https://api.github.com/repos/tgriesser/knex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tgriesser/knex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tgriesser/knex/git/refs{/sha}","trees_url":"https://api.github.com/repos/tgriesser/knex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tgriesser/knex/statuses/{sha}","languages_url":"https://api.github.com/repos/tgriesser/knex/languages","stargazers_url":"https://api.github.com/repos/tgriesser/knex/stargazers","contributors_url":"https://api.github.com/repos/tgriesser/knex/contributors","subscribers_url":"https://api.github.com/repos/tgriesser/knex/subscribers","subscription_url":"https://api.github.com/repos/tgriesser/knex/subscription","commits_url":"https://api.github.com/repos/tgriesser/knex/commits{/sha}","git_commits_url":"https://api.github.com/repos/tgriesser/knex/git/commits{/sha}","comments_url":"https://api.github.com/repos/tgriesser/knex/comments{/number}","issue_comment_url":"https://api.github.com/repos/tgriesser/knex/issues/comments{/number}","contents_url":"https://api.github.com/repos/tgriesser/knex/contents/{+path}","compare_url":"https://api.github.com/repos/tgriesser/knex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tgriesser/knex/merges","archive_url":"https://api.github.com/repos/tgriesser/knex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tgriesser/knex/downloads","issues_url":"https://api.github.com/repos/tgriesser/knex/issues{/number}","pulls_url":"https://api.github.com/repos/tgriesser/knex/pulls{/number}","milestones_url":"https://api.github.com/repos/tgriesser/knex/milestones{/number}","notifications_url":"https://api.github.com/repos/tgriesser/knex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tgriesser/knex/labels{/name}","releases_url":"https://api.github.com/repos/tgriesser/knex/releases{/id}","created_at":"2012-12-29T05:18:25Z","updated_at":"2015-12-01T03:46:03Z","pushed_at":"2015-11-30T23:32:55Z","git_url":"git://github.com/tgriesser/knex.git","ssh_url":"git@github.com:tgriesser/knex.git","clone_url":"https://github.com/tgriesser/knex.git","svn_url":"https://github.com/tgriesser/knex","homepage":"knexjs.org","size":6074,"stargazers_count":2056,"watchers_count":2056,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":307,"mirror_url":null,"open_issues_count":278,"forks":307,"open_issues":278,"watchers":2056,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tgriesser/knex/pulls/1067"},"html":{"href":"https://github.com/tgriesser/knex/pull/1067"},"issue":{"href":"https://api.github.com/repos/tgriesser/knex/issues/1067"},"comments":{"href":"https://api.github.com/repos/tgriesser/knex/issues/1067/comments"},"review_comments":{"href":"https://api.github.com/repos/tgriesser/knex/pulls/1067/comments"},"review_comment":{"href":"https://api.github.com/repos/tgriesser/knex/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tgriesser/knex/pulls/1067/commits"},"statuses":{"href":"https://api.github.com/repos/tgriesser/knex/statuses/cce1159ac0128d5ee7fdd53222e4d16701bb1465"}}}}