{"action":"created","issue":{"url":"https://api.github.com/repos/cubing/worldcubeassociation.org/issues/625","repository_url":"https://api.github.com/repos/cubing/worldcubeassociation.org","labels_url":"https://api.github.com/repos/cubing/worldcubeassociation.org/issues/625/labels{/name}","comments_url":"https://api.github.com/repos/cubing/worldcubeassociation.org/issues/625/comments","events_url":"https://api.github.com/repos/cubing/worldcubeassociation.org/issues/625/events","html_url":"https://github.com/cubing/worldcubeassociation.org/issues/625","id":155190005,"number":625,"title":"Foreign Keys","user":{"login":"FatBoyXPC","id":744962,"avatar_url":"https://avatars.githubusercontent.com/u/744962?v=3","gravatar_id":"","url":"https://api.github.com/users/FatBoyXPC","html_url":"https://github.com/FatBoyXPC","followers_url":"https://api.github.com/users/FatBoyXPC/followers","following_url":"https://api.github.com/users/FatBoyXPC/following{/other_user}","gists_url":"https://api.github.com/users/FatBoyXPC/gists{/gist_id}","starred_url":"https://api.github.com/users/FatBoyXPC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FatBoyXPC/subscriptions","organizations_url":"https://api.github.com/users/FatBoyXPC/orgs","repos_url":"https://api.github.com/users/FatBoyXPC/repos","events_url":"https://api.github.com/users/FatBoyXPC/events{/privacy}","received_events_url":"https://api.github.com/users/FatBoyXPC/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-17T07:03:53Z","updated_at":"2016-05-17T16:10:49Z","closed_at":null,"body":"It appears as some tables don't have appropriate foreign keys setup. Currently, the following tables don't have foreign keys setup:\r\n\r\nTable | Field w/o FK\r\n--- | ---\r\ncompetition_delegates | delegate_id\r\ncompetition_organizers | organizer_id\r\noauth_access_grants | resource_owner_id\r\noauth_access_tokens | resource_owner_id\r\noauth_applications | owner_id\r\nposts | author_id\r\nteam_members | user_id\r\nuser_preferred_events | user_id\r\nvotes | poll_id\r\nvote_options | vote_id, poll_option_id"},"comment":{"url":"https://api.github.com/repos/cubing/worldcubeassociation.org/issues/comments/219768775","html_url":"https://github.com/cubing/worldcubeassociation.org/issues/625#issuecomment-219768775","issue_url":"https://api.github.com/repos/cubing/worldcubeassociation.org/issues/625","id":219768775,"user":{"login":"FatBoyXPC","id":744962,"avatar_url":"https://avatars.githubusercontent.com/u/744962?v=3","gravatar_id":"","url":"https://api.github.com/users/FatBoyXPC","html_url":"https://github.com/FatBoyXPC","followers_url":"https://api.github.com/users/FatBoyXPC/followers","following_url":"https://api.github.com/users/FatBoyXPC/following{/other_user}","gists_url":"https://api.github.com/users/FatBoyXPC/gists{/gist_id}","starred_url":"https://api.github.com/users/FatBoyXPC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FatBoyXPC/subscriptions","organizations_url":"https://api.github.com/users/FatBoyXPC/orgs","repos_url":"https://api.github.com/users/FatBoyXPC/repos","events_url":"https://api.github.com/users/FatBoyXPC/events{/privacy}","received_events_url":"https://api.github.com/users/FatBoyXPC/received_events","type":"User","site_admin":false},"created_at":"2016-05-17T16:10:48Z","updated_at":"2016-05-17T16:10:48Z","body":"So regardless of what the rails convention way of doing things is, foreign keys are a **good** thing. That said, The rails documentation actually discusses primary keys with \"associations\" [here](http://guides.rubyonrails.org/v2.3.11/association_basics.html#the-types-of-associations):\r\n\r\nFor example, by declaring that one model belongs_to another, you instruct Rails to maintain Primary Key–Foreign Key information between instances of the two models, and you also get a number of utility methods added to your model"}}