{"action":"closed","issue":{"url":"https://api.github.com/repos/lancetw/react-isomorphic-bundle/issues/5","labels_url":"https://api.github.com/repos/lancetw/react-isomorphic-bundle/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/lancetw/react-isomorphic-bundle/issues/5/comments","events_url":"https://api.github.com/repos/lancetw/react-isomorphic-bundle/issues/5/events","html_url":"https://github.com/lancetw/react-isomorphic-bundle/issues/5","id":109111217,"number":5,"title":"User model issue","user":{"login":"kikoanis","id":615849,"avatar_url":"https://avatars.githubusercontent.com/u/615849?v=3","gravatar_id":"","url":"https://api.github.com/users/kikoanis","html_url":"https://github.com/kikoanis","followers_url":"https://api.github.com/users/kikoanis/followers","following_url":"https://api.github.com/users/kikoanis/following{/other_user}","gists_url":"https://api.github.com/users/kikoanis/gists{/gist_id}","starred_url":"https://api.github.com/users/kikoanis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kikoanis/subscriptions","organizations_url":"https://api.github.com/users/kikoanis/orgs","repos_url":"https://api.github.com/users/kikoanis/repos","events_url":"https://api.github.com/users/kikoanis/events{/privacy}","received_events_url":"https://api.github.com/users/kikoanis/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-30T15:04:34Z","updated_at":"2015-09-30T17:50:08Z","closed_at":"2015-09-30T17:50:08Z","body":"User model associates posts model and userInfo model based on id foreign key. That will create a new constraint on both posts and userInfo tables that associate id to users table where it should be uid to users table. Hence this will cause a potential bigger issue of failure if you try to insert a post that points to non-existing user id or it may point to the wrong one.\r\n\r\nThese are the offensive lines\r\nhttps://github.com/lancetw/react-isomorphic-bundle/blob/master/src/server/db/models/user.js#L32\r\nhttps://github.com/lancetw/react-isomorphic-bundle/blob/master/src/server/db/models/user.js#L35\r\n\r\n![capture](https://cloud.githubusercontent.com/assets/615849/10197348/568ff3ce-6754-11e5-8cec-1839b8ac048a.PNG)\r\n\r\nthey should pont to uid like so...\r\n```\r\nassociate: function (models) {\r\n        User.hasMany(models.posts, {\r\n          foreignKey: 'uid'\r\n        });\r\n        User.hasOne(models.usersInfo, {\r\n          foreignKey: 'uid'\r\n        });\r\n      }\r\n```\r\n"}}