{"action":"created","issue":{"url":"https://api.github.com/repos/waiting-for-dev/devise-jwt/issues/85","repository_url":"https://api.github.com/repos/waiting-for-dev/devise-jwt","labels_url":"https://api.github.com/repos/waiting-for-dev/devise-jwt/issues/85/labels{/name}","comments_url":"https://api.github.com/repos/waiting-for-dev/devise-jwt/issues/85/comments","events_url":"https://api.github.com/repos/waiting-for-dev/devise-jwt/issues/85/events","html_url":"https://github.com/waiting-for-dev/devise-jwt/issues/85","id":305252043,"number":85,"title":"Add stricter referential integrity to WhitelistedJwt migration","user":{"login":"christophweegen","id":18473775,"avatar_url":"https://avatars0.githubusercontent.com/u/18473775?v=4","gravatar_id":"","url":"https://api.github.com/users/christophweegen","html_url":"https://github.com/christophweegen","followers_url":"https://api.github.com/users/christophweegen/followers","following_url":"https://api.github.com/users/christophweegen/following{/other_user}","gists_url":"https://api.github.com/users/christophweegen/gists{/gist_id}","starred_url":"https://api.github.com/users/christophweegen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christophweegen/subscriptions","organizations_url":"https://api.github.com/users/christophweegen/orgs","repos_url":"https://api.github.com/users/christophweegen/repos","events_url":"https://api.github.com/users/christophweegen/events{/privacy}","received_events_url":"https://api.github.com/users/christophweegen/received_events","type":"User","site_admin":false},"labels":[{"id":516708600,"url":"https://api.github.com/repos/waiting-for-dev/devise-jwt/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-03-14T17:14:52Z","updated_at":"2018-04-13T13:10:07Z","closed_at":"2018-04-13T13:10:07Z","author_association":"CONTRIBUTOR","body":"A thing that came to my mind while using whitelisted strategy:\r\n\r\nShouldn't the migration for whitelisted jwts user reference look like this\r\n\r\n`t.references :user, foreign_key: { on_delete: :cascade }, null: false`\r\n\r\ninstead of\r\n\r\n`t.references :user, foreign_key: true`\r\n\r\nsince you never want to store whitelisted jwts for a user that got deleted, so every associated whitelisted jwt get instantly deleted when a user is deleted? \r\n\r\nAdditionally you don't want to have whitelisted jwts in your database that don't point to a user. So setting it to `null: false` makes this is a bit stricter. \r\n\r\nI always like to add referential integrity to the database as best as possible, cause it can help prevent bugs when you can trust that only allowed values are saved to the database and you instantly get noticed about it in development if you try to save something invalid. That's not always the case if you just rely on rails validations.\r\n\r\nI like this blog post about that topic https://robots.thoughtbot.com/referential-integrity-with-foreign-keys just in case you didn't already read it."},"comment":{"url":"https://api.github.com/repos/waiting-for-dev/devise-jwt/issues/comments/381130200","html_url":"https://github.com/waiting-for-dev/devise-jwt/issues/85#issuecomment-381130200","issue_url":"https://api.github.com/repos/waiting-for-dev/devise-jwt/issues/85","id":381130200,"user":{"login":"waiting-for-dev","id":52650,"avatar_url":"https://avatars1.githubusercontent.com/u/52650?v=4","gravatar_id":"","url":"https://api.github.com/users/waiting-for-dev","html_url":"https://github.com/waiting-for-dev","followers_url":"https://api.github.com/users/waiting-for-dev/followers","following_url":"https://api.github.com/users/waiting-for-dev/following{/other_user}","gists_url":"https://api.github.com/users/waiting-for-dev/gists{/gist_id}","starred_url":"https://api.github.com/users/waiting-for-dev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waiting-for-dev/subscriptions","organizations_url":"https://api.github.com/users/waiting-for-dev/orgs","repos_url":"https://api.github.com/users/waiting-for-dev/repos","events_url":"https://api.github.com/users/waiting-for-dev/events{/privacy}","received_events_url":"https://api.github.com/users/waiting-for-dev/received_events","type":"User","site_admin":false},"created_at":"2018-04-13T13:10:06Z","updated_at":"2018-04-13T13:10:06Z","author_association":"OWNER","body":"Closed by #89 "}}
{"actor":{"display_login":"waiting-for-dev"}}