{"action":"created","comment":{"url":"https://api.github.com/repos/rails/rails/pulls/comments/23721301","id":23721301,"diff_hunk":"@@ -671,6 +671,29 @@ def remove_reference(table_name, ref_name, options = {})\n       def foreign_keys(table_name)\n         raise NotImplementedError, \"foreign_keys is not implemented\"\n       end\n+      \n+      # Checks to see if a foreign key exists on a table for a given foreign key definition.\n+      #\n+      #   # Check a foreign key exists\n+      #   foreign_key_exists?(:accounts, :branches)\n+      #\n+      #   # Check a foreign key on specified column exists\n+      #   foreign_key_exists?(:accounts, column: :owner_id)\n+      #\n+      #   # Check a foreign key with a custom name exists\n+      #   foreign_key_exists?(:accounts, name: \"special_fk_name\")\n+      #\n+      def foreign_key_exists?(from_table, options_or_to_table = {})\n+        return unless supports_foreign_keys?","path":"activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb","position":17,"original_position":17,"commit_id":"6298ac705da92cc793cbf40dd91484d34e01d255","original_commit_id":"6298ac705da92cc793cbf40dd91484d34e01d255","user":{"login":"ianks","id":3303032,"avatar_url":"https://avatars.githubusercontent.com/u/3303032?v=3","gravatar_id":"","url":"https://api.github.com/users/ianks","html_url":"https://github.com/ianks","followers_url":"https://api.github.com/users/ianks/followers","following_url":"https://api.github.com/users/ianks/following{/other_user}","gists_url":"https://api.github.com/users/ianks/gists{/gist_id}","starred_url":"https://api.github.com/users/ianks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ianks/subscriptions","organizations_url":"https://api.github.com/users/ianks/orgs","repos_url":"https://api.github.com/users/ianks/repos","events_url":"https://api.github.com/users/ianks/events{/privacy}","received_events_url":"https://api.github.com/users/ianks/received_events","type":"User","site_admin":false},"body":"We should probably return false instead of nil here to maintain convention with most Ruby `.exist?` functions.","created_at":"2015-01-28T20:38:13Z","updated_at":"2015-01-28T20:38:13Z","html_url":"https://github.com/rails/rails/pull/18662#discussion_r23721301","pull_request_url":"https://api.github.com/repos/rails/rails/pulls/18662","_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/23721301"},"html":{"href":"https://github.com/rails/rails/pull/18662#discussion_r23721301"},"pull_request":{"href":"https://api.github.com/repos/rails/rails/pulls/18662"}}},"pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/18662","id":27956404,"html_url":"https://github.com/rails/rails/pull/18662","diff_url":"https://github.com/rails/rails/pull/18662.diff","patch_url":"https://github.com/rails/rails/pull/18662.patch","issue_url":"https://api.github.com/repos/rails/rails/issues/18662","number":18662,"state":"open","locked":false,"title":"Add `foreign_key_exists?` method.","user":{"login":"estum","id":1584968,"avatar_url":"https://avatars.githubusercontent.com/u/1584968?v=3","gravatar_id":"","url":"https://api.github.com/users/estum","html_url":"https://github.com/estum","followers_url":"https://api.github.com/users/estum/followers","following_url":"https://api.github.com/users/estum/following{/other_user}","gists_url":"https://api.github.com/users/estum/gists{/gist_id}","starred_url":"https://api.github.com/users/estum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estum/subscriptions","organizations_url":"https://api.github.com/users/estum/orgs","repos_url":"https://api.github.com/users/estum/repos","events_url":"https://api.github.com/users/estum/events{/privacy}","received_events_url":"https://api.github.com/users/estum/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-23T21:21:38Z","updated_at":"2015-01-28T20:38:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d228e4aa679e1c90a6b06f25e4e8daf8e96496bf","assignee":null,"milestone":{"url":"https://api.github.com/repos/rails/rails/milestones/34","labels_url":"https://api.github.com/repos/rails/rails/milestones/34/labels","id":665192,"number":34,"title":"5.0.0","description":null,"creator":{"login":"rafaelfranca","id":47848,"avatar_url":"https://avatars.githubusercontent.com/u/47848?v=3","gravatar_id":"","url":"https://api.github.com/users/rafaelfranca","html_url":"https://github.com/rafaelfranca","followers_url":"https://api.github.com/users/rafaelfranca/followers","following_url":"https://api.github.com/users/rafaelfranca/following{/other_user}","gists_url":"https://api.github.com/users/rafaelfranca/gists{/gist_id}","starred_url":"https://api.github.com/users/rafaelfranca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafaelfranca/subscriptions","organizations_url":"https://api.github.com/users/rafaelfranca/orgs","repos_url":"https://api.github.com/users/rafaelfranca/repos","events_url":"https://api.github.com/users/rafaelfranca/events{/privacy}","received_events_url":"https://api.github.com/users/rafaelfranca/received_events","type":"User","site_admin":false},"open_issues":94,"closed_issues":50,"state":"open","created_at":"2014-05-21T00:58:22Z","updated_at":"2015-01-28T20:31:43Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/rails/rails/pulls/18662/commits","review_comments_url":"https://api.github.com/repos/rails/rails/pulls/18662/comments","review_comment_url":"https://api.github.com/repos/rails/rails/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rails/rails/issues/18662/comments","statuses_url":"https://api.github.com/repos/rails/rails/statuses/6298ac705da92cc793cbf40dd91484d34e01d255","head":{"label":"estum:foreign-key-exists","ref":"foreign-key-exists","sha":"6298ac705da92cc793cbf40dd91484d34e01d255","user":{"login":"estum","id":1584968,"avatar_url":"https://avatars.githubusercontent.com/u/1584968?v=3","gravatar_id":"","url":"https://api.github.com/users/estum","html_url":"https://github.com/estum","followers_url":"https://api.github.com/users/estum/followers","following_url":"https://api.github.com/users/estum/following{/other_user}","gists_url":"https://api.github.com/users/estum/gists{/gist_id}","starred_url":"https://api.github.com/users/estum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estum/subscriptions","organizations_url":"https://api.github.com/users/estum/orgs","repos_url":"https://api.github.com/users/estum/repos","events_url":"https://api.github.com/users/estum/events{/privacy}","received_events_url":"https://api.github.com/users/estum/received_events","type":"User","site_admin":false},"repo":{"id":29747451,"name":"rails","full_name":"estum/rails","owner":{"login":"estum","id":1584968,"avatar_url":"https://avatars.githubusercontent.com/u/1584968?v=3","gravatar_id":"","url":"https://api.github.com/users/estum","html_url":"https://github.com/estum","followers_url":"https://api.github.com/users/estum/followers","following_url":"https://api.github.com/users/estum/following{/other_user}","gists_url":"https://api.github.com/users/estum/gists{/gist_id}","starred_url":"https://api.github.com/users/estum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/estum/subscriptions","organizations_url":"https://api.github.com/users/estum/orgs","repos_url":"https://api.github.com/users/estum/repos","events_url":"https://api.github.com/users/estum/events{/privacy}","received_events_url":"https://api.github.com/users/estum/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/estum/rails","description":"Ruby on Rails","fork":true,"url":"https://api.github.com/repos/estum/rails","forks_url":"https://api.github.com/repos/estum/rails/forks","keys_url":"https://api.github.com/repos/estum/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/estum/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/estum/rails/teams","hooks_url":"https://api.github.com/repos/estum/rails/hooks","issue_events_url":"https://api.github.com/repos/estum/rails/issues/events{/number}","events_url":"https://api.github.com/repos/estum/rails/events","assignees_url":"https://api.github.com/repos/estum/rails/assignees{/user}","branches_url":"https://api.github.com/repos/estum/rails/branches{/branch}","tags_url":"https://api.github.com/repos/estum/rails/tags","blobs_url":"https://api.github.com/repos/estum/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/estum/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/estum/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/estum/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/estum/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/estum/rails/languages","stargazers_url":"https://api.github.com/repos/estum/rails/stargazers","contributors_url":"https://api.github.com/repos/estum/rails/contributors","subscribers_url":"https://api.github.com/repos/estum/rails/subscribers","subscription_url":"https://api.github.com/repos/estum/rails/subscription","commits_url":"https://api.github.com/repos/estum/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/estum/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/estum/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/estum/rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/estum/rails/contents/{+path}","compare_url":"https://api.github.com/repos/estum/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/estum/rails/merges","archive_url":"https://api.github.com/repos/estum/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/estum/rails/downloads","issues_url":"https://api.github.com/repos/estum/rails/issues{/number}","pulls_url":"https://api.github.com/repos/estum/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/estum/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/estum/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/estum/rails/labels{/name}","releases_url":"https://api.github.com/repos/estum/rails/releases{/id}","created_at":"2015-01-23T18:49:21Z","updated_at":"2015-01-23T18:50:40Z","pushed_at":"2015-01-23T21:20:45Z","git_url":"git://github.com/estum/rails.git","ssh_url":"git@github.com:estum/rails.git","clone_url":"https://github.com/estum/rails.git","svn_url":"https://github.com/estum/rails","homepage":"http://rubyonrails.org","size":127152,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"rails:master","ref":"master","sha":"96e504ec8af149962312c13dd418e13e4c74ce86","user":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"repo":{"id":8514,"name":"rails","full_name":"rails/rails","owner":{"login":"rails","id":4223,"avatar_url":"https://avatars.githubusercontent.com/u/4223?v=3","gravatar_id":"","url":"https://api.github.com/users/rails","html_url":"https://github.com/rails","followers_url":"https://api.github.com/users/rails/followers","following_url":"https://api.github.com/users/rails/following{/other_user}","gists_url":"https://api.github.com/users/rails/gists{/gist_id}","starred_url":"https://api.github.com/users/rails/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails/subscriptions","organizations_url":"https://api.github.com/users/rails/orgs","repos_url":"https://api.github.com/users/rails/repos","events_url":"https://api.github.com/users/rails/events{/privacy}","received_events_url":"https://api.github.com/users/rails/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails/rails","description":"Ruby on Rails","fork":false,"url":"https://api.github.com/repos/rails/rails","forks_url":"https://api.github.com/repos/rails/rails/forks","keys_url":"https://api.github.com/repos/rails/rails/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails/rails/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails/rails/teams","hooks_url":"https://api.github.com/repos/rails/rails/hooks","issue_events_url":"https://api.github.com/repos/rails/rails/issues/events{/number}","events_url":"https://api.github.com/repos/rails/rails/events","assignees_url":"https://api.github.com/repos/rails/rails/assignees{/user}","branches_url":"https://api.github.com/repos/rails/rails/branches{/branch}","tags_url":"https://api.github.com/repos/rails/rails/tags","blobs_url":"https://api.github.com/repos/rails/rails/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails/rails/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails/rails/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails/rails/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails/rails/statuses/{sha}","languages_url":"https://api.github.com/repos/rails/rails/languages","stargazers_url":"https://api.github.com/repos/rails/rails/stargazers","contributors_url":"https://api.github.com/repos/rails/rails/contributors","subscribers_url":"https://api.github.com/repos/rails/rails/subscribers","subscription_url":"https://api.github.com/repos/rails/rails/subscription","commits_url":"https://api.github.com/repos/rails/rails/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails/rails/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails/rails/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails/rails/issues/comments/{number}","contents_url":"https://api.github.com/repos/rails/rails/contents/{+path}","compare_url":"https://api.github.com/repos/rails/rails/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails/rails/merges","archive_url":"https://api.github.com/repos/rails/rails/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails/rails/downloads","issues_url":"https://api.github.com/repos/rails/rails/issues{/number}","pulls_url":"https://api.github.com/repos/rails/rails/pulls{/number}","milestones_url":"https://api.github.com/repos/rails/rails/milestones{/number}","notifications_url":"https://api.github.com/repos/rails/rails/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails/rails/labels{/name}","releases_url":"https://api.github.com/repos/rails/rails/releases{/id}","created_at":"2008-04-11T02:19:47Z","updated_at":"2015-01-28T20:20:25Z","pushed_at":"2015-01-28T20:22:20Z","git_url":"git://github.com/rails/rails.git","ssh_url":"git@github.com:rails/rails.git","clone_url":"https://github.com/rails/rails.git","svn_url":"https://github.com/rails/rails","homepage":"http://rubyonrails.org","size":364330,"stargazers_count":24734,"watchers_count":24734,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9583,"mirror_url":null,"open_issues_count":767,"forks":9583,"open_issues":767,"watchers":24734,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails/rails/pulls/18662"},"html":{"href":"https://github.com/rails/rails/pull/18662"},"issue":{"href":"https://api.github.com/repos/rails/rails/issues/18662"},"comments":{"href":"https://api.github.com/repos/rails/rails/issues/18662/comments"},"review_comments":{"href":"https://api.github.com/repos/rails/rails/pulls/18662/comments"},"review_comment":{"href":"https://api.github.com/repos/rails/rails/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rails/rails/pulls/18662/commits"},"statuses":{"href":"https://api.github.com/repos/rails/rails/statuses/6298ac705da92cc793cbf40dd91484d34e01d255"}}}}