{"action":"created","comment":{"url":"https://api.github.com/repos/3scale/porta/pulls/comments/240566726","pull_request_review_id":183622303,"id":240566726,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0MDU2NjcyNg==","diff_hunk":"@@ -5,7 +5,7 @@ def self.create(account)\n       account_name: account.name,\n       provider:     account.provider_account,\n       buyer:        account.buyer,\n-      user_id:      account.first_admin.try(:id),\n+      user_id:      account.first_admin.try(:id) || account.first_admin_id,","path":"app/events/accounts/account_deleted_event.rb","position":5,"original_position":5,"commit_id":"f1f94056dff9aad199ba875f8b312fc632adc438","original_commit_id":"f1f94056dff9aad199ba875f8b312fc632adc438","user":{"login":"hallelujah","id":64276,"node_id":"MDQ6VXNlcjY0Mjc2","avatar_url":"https://avatars3.githubusercontent.com/u/64276?v=4","gravatar_id":"","url":"https://api.github.com/users/hallelujah","html_url":"https://github.com/hallelujah","followers_url":"https://api.github.com/users/hallelujah/followers","following_url":"https://api.github.com/users/hallelujah/following{/other_user}","gists_url":"https://api.github.com/users/hallelujah/gists{/gist_id}","starred_url":"https://api.github.com/users/hallelujah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hallelujah/subscriptions","organizations_url":"https://api.github.com/users/hallelujah/orgs","repos_url":"https://api.github.com/users/hallelujah/repos","events_url":"https://api.github.com/users/hallelujah/events{/privacy}","received_events_url":"https://api.github.com/users/hallelujah/received_events","type":"User","site_admin":false},"body":"I would do in Account `alias_attribute :first_admin_id_on_provider_signup, :first_admin_id`\r\n\r\nAnd somehow add a comment to this PR","created_at":"2018-12-11T11:11:18Z","updated_at":"2018-12-11T11:11:19Z","html_url":"https://github.com/3scale/porta/pull/8#discussion_r240566726","pull_request_url":"https://api.github.com/repos/3scale/porta/pulls/8","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/3scale/porta/pulls/comments/240566726"},"html":{"href":"https://github.com/3scale/porta/pull/8#discussion_r240566726"},"pull_request":{"href":"https://api.github.com/repos/3scale/porta/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/3scale/porta/pulls/8","id":216568221,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2NTY4MjIx","html_url":"https://github.com/3scale/porta/pull/8","diff_url":"https://github.com/3scale/porta/pull/8.diff","patch_url":"https://github.com/3scale/porta/pull/8.patch","issue_url":"https://api.github.com/repos/3scale/porta/issues/8","number":8,"state":"open","locked":false,"title":"[Bugfix][Spike] NotificationDeliveryService::InvalidEventError for AccountDeletedEvent","user":{"login":"Martouta","id":11318903,"node_id":"MDQ6VXNlcjExMzE4OTAz","avatar_url":"https://avatars1.githubusercontent.com/u/11318903?v=4","gravatar_id":"","url":"https://api.github.com/users/Martouta","html_url":"https://github.com/Martouta","followers_url":"https://api.github.com/users/Martouta/followers","following_url":"https://api.github.com/users/Martouta/following{/other_user}","gists_url":"https://api.github.com/users/Martouta/gists{/gist_id}","starred_url":"https://api.github.com/users/Martouta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martouta/subscriptions","organizations_url":"https://api.github.com/users/Martouta/orgs","repos_url":"https://api.github.com/users/Martouta/repos","events_url":"https://api.github.com/users/Martouta/events{/privacy}","received_events_url":"https://api.github.com/users/Martouta/received_events","type":"User","site_admin":false},"body":"Solution to the 2nd problem of the issue and fix https://github.com/3scale/porta/issues/10\r\n\r\nAdd an extra column to the accounts table to save always its first admin user_id.\r\nThis specifically means:\r\n- [x] Add the `first_admin_id` column to the accounts table\r\n- [x] Fetch all current providers and save its `first_admin_id`\r\n- [x] When an admin user is deleted, it is set to the next one IF there is a next one AND the account has not been removed yet.\r\n- [x] When the first admin user is created, update the account `first_admin_id`\r\n\r\nThere is a still condition but much easier. They will check each other if they are the last admin\r\nOne of them will be updated last, it doesn't matter which one for now, so it will not end up being nil, but one of those 2 randomly instead.\r\n\r\nIf this is correct, this also implies telling ops to run the migration on SaaS 😄https://github.com/3scale/infrastructure/issues/597 ","created_at":"2018-09-19T09:16:40Z","updated_at":"2018-12-11T11:11:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ac39b5c4d995bd0c680613d0853ebd441539dc77","assignee":{"login":"Martouta","id":11318903,"node_id":"MDQ6VXNlcjExMzE4OTAz","avatar_url":"https://avatars1.githubusercontent.com/u/11318903?v=4","gravatar_id":"","url":"https://api.github.com/users/Martouta","html_url":"https://github.com/Martouta","followers_url":"https://api.github.com/users/Martouta/followers","following_url":"https://api.github.com/users/Martouta/following{/other_user}","gists_url":"https://api.github.com/users/Martouta/gists{/gist_id}","starred_url":"https://api.github.com/users/Martouta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martouta/subscriptions","organizations_url":"https://api.github.com/users/Martouta/orgs","repos_url":"https://api.github.com/users/Martouta/repos","events_url":"https://api.github.com/users/Martouta/events{/privacy}","received_events_url":"https://api.github.com/users/Martouta/received_events","type":"User","site_admin":false},"assignees":[{"login":"Martouta","id":11318903,"node_id":"MDQ6VXNlcjExMzE4OTAz","avatar_url":"https://avatars1.githubusercontent.com/u/11318903?v=4","gravatar_id":"","url":"https://api.github.com/users/Martouta","html_url":"https://github.com/Martouta","followers_url":"https://api.github.com/users/Martouta/followers","following_url":"https://api.github.com/users/Martouta/following{/other_user}","gists_url":"https://api.github.com/users/Martouta/gists{/gist_id}","starred_url":"https://api.github.com/users/Martouta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Martouta/subscriptions","organizations_url":"https://api.github.com/users/Martouta/orgs","repos_url":"https://api.github.com/users/Martouta/repos","events_url":"https://api.github.com/users/Martouta/events{/privacy}","received_events_url":"https://api.github.com/users/Martouta/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"macejmic","id":4996128,"node_id":"MDQ6VXNlcjQ5OTYxMjg=","avatar_url":"https://avatars1.githubusercontent.com/u/4996128?v=4","gravatar_id":"","url":"https://api.github.com/users/macejmic","html_url":"https://github.com/macejmic","followers_url":"https://api.github.com/users/macejmic/followers","following_url":"https://api.github.com/users/macejmic/following{/other_user}","gists_url":"https://api.github.com/users/macejmic/gists{/gist_id}","starred_url":"https://api.github.com/users/macejmic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macejmic/subscriptions","organizations_url":"https://api.github.com/users/macejmic/orgs","repos_url":"https://api.github.com/users/macejmic/repos","events_url":"https://api.github.com/users/macejmic/events{/privacy}","received_events_url":"https://api.github.com/users/macejmic/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/3scale/porta/pulls/8/commits","review_comments_url":"https://api.github.com/repos/3scale/porta/pulls/8/comments","review_comment_url":"https://api.github.com/repos/3scale/porta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/3scale/porta/issues/8/comments","statuses_url":"https://api.github.com/repos/3scale/porta/statuses/f1f94056dff9aad199ba875f8b312fc632adc438","head":{"label":"3scale:spike-account-deleted-event-invalid","ref":"spike-account-deleted-event-invalid","sha":"f1f94056dff9aad199ba875f8b312fc632adc438","user":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"repo":{"id":149315920,"node_id":"MDEwOlJlcG9zaXRvcnkxNDkzMTU5MjA=","name":"porta","full_name":"3scale/porta","private":false,"owner":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/3scale/porta","description":"Red Hat 3scale API Management, Porta","fork":false,"url":"https://api.github.com/repos/3scale/porta","forks_url":"https://api.github.com/repos/3scale/porta/forks","keys_url":"https://api.github.com/repos/3scale/porta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3scale/porta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3scale/porta/teams","hooks_url":"https://api.github.com/repos/3scale/porta/hooks","issue_events_url":"https://api.github.com/repos/3scale/porta/issues/events{/number}","events_url":"https://api.github.com/repos/3scale/porta/events","assignees_url":"https://api.github.com/repos/3scale/porta/assignees{/user}","branches_url":"https://api.github.com/repos/3scale/porta/branches{/branch}","tags_url":"https://api.github.com/repos/3scale/porta/tags","blobs_url":"https://api.github.com/repos/3scale/porta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3scale/porta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3scale/porta/git/refs{/sha}","trees_url":"https://api.github.com/repos/3scale/porta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3scale/porta/statuses/{sha}","languages_url":"https://api.github.com/repos/3scale/porta/languages","stargazers_url":"https://api.github.com/repos/3scale/porta/stargazers","contributors_url":"https://api.github.com/repos/3scale/porta/contributors","subscribers_url":"https://api.github.com/repos/3scale/porta/subscribers","subscription_url":"https://api.github.com/repos/3scale/porta/subscription","commits_url":"https://api.github.com/repos/3scale/porta/commits{/sha}","git_commits_url":"https://api.github.com/repos/3scale/porta/git/commits{/sha}","comments_url":"https://api.github.com/repos/3scale/porta/comments{/number}","issue_comment_url":"https://api.github.com/repos/3scale/porta/issues/comments{/number}","contents_url":"https://api.github.com/repos/3scale/porta/contents/{+path}","compare_url":"https://api.github.com/repos/3scale/porta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3scale/porta/merges","archive_url":"https://api.github.com/repos/3scale/porta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3scale/porta/downloads","issues_url":"https://api.github.com/repos/3scale/porta/issues{/number}","pulls_url":"https://api.github.com/repos/3scale/porta/pulls{/number}","milestones_url":"https://api.github.com/repos/3scale/porta/milestones{/number}","notifications_url":"https://api.github.com/repos/3scale/porta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3scale/porta/labels{/name}","releases_url":"https://api.github.com/repos/3scale/porta/releases{/id}","deployments_url":"https://api.github.com/repos/3scale/porta/deployments","created_at":"2018-09-18T16:03:13Z","updated_at":"2018-12-11T11:02:43Z","pushed_at":"2018-12-11T11:08:51Z","git_url":"git://github.com/3scale/porta.git","ssh_url":"git@github.com:3scale/porta.git","clone_url":"https://github.com/3scale/porta.git","svn_url":"https://github.com/3scale/porta","homepage":"","size":36309,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":4,"open_issues":34,"watchers":12,"default_branch":"master"}},"base":{"label":"3scale:master","ref":"master","sha":"fa75bfe73f9a6cf7a4dfbb9b0a00f5055fb8fb3b","user":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"repo":{"id":149315920,"node_id":"MDEwOlJlcG9zaXRvcnkxNDkzMTU5MjA=","name":"porta","full_name":"3scale/porta","private":false,"owner":{"login":"3scale","id":21415,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIxNDE1","avatar_url":"https://avatars0.githubusercontent.com/u/21415?v=4","gravatar_id":"","url":"https://api.github.com/users/3scale","html_url":"https://github.com/3scale","followers_url":"https://api.github.com/users/3scale/followers","following_url":"https://api.github.com/users/3scale/following{/other_user}","gists_url":"https://api.github.com/users/3scale/gists{/gist_id}","starred_url":"https://api.github.com/users/3scale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3scale/subscriptions","organizations_url":"https://api.github.com/users/3scale/orgs","repos_url":"https://api.github.com/users/3scale/repos","events_url":"https://api.github.com/users/3scale/events{/privacy}","received_events_url":"https://api.github.com/users/3scale/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/3scale/porta","description":"Red Hat 3scale API Management, Porta","fork":false,"url":"https://api.github.com/repos/3scale/porta","forks_url":"https://api.github.com/repos/3scale/porta/forks","keys_url":"https://api.github.com/repos/3scale/porta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/3scale/porta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/3scale/porta/teams","hooks_url":"https://api.github.com/repos/3scale/porta/hooks","issue_events_url":"https://api.github.com/repos/3scale/porta/issues/events{/number}","events_url":"https://api.github.com/repos/3scale/porta/events","assignees_url":"https://api.github.com/repos/3scale/porta/assignees{/user}","branches_url":"https://api.github.com/repos/3scale/porta/branches{/branch}","tags_url":"https://api.github.com/repos/3scale/porta/tags","blobs_url":"https://api.github.com/repos/3scale/porta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/3scale/porta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/3scale/porta/git/refs{/sha}","trees_url":"https://api.github.com/repos/3scale/porta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/3scale/porta/statuses/{sha}","languages_url":"https://api.github.com/repos/3scale/porta/languages","stargazers_url":"https://api.github.com/repos/3scale/porta/stargazers","contributors_url":"https://api.github.com/repos/3scale/porta/contributors","subscribers_url":"https://api.github.com/repos/3scale/porta/subscribers","subscription_url":"https://api.github.com/repos/3scale/porta/subscription","commits_url":"https://api.github.com/repos/3scale/porta/commits{/sha}","git_commits_url":"https://api.github.com/repos/3scale/porta/git/commits{/sha}","comments_url":"https://api.github.com/repos/3scale/porta/comments{/number}","issue_comment_url":"https://api.github.com/repos/3scale/porta/issues/comments{/number}","contents_url":"https://api.github.com/repos/3scale/porta/contents/{+path}","compare_url":"https://api.github.com/repos/3scale/porta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/3scale/porta/merges","archive_url":"https://api.github.com/repos/3scale/porta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/3scale/porta/downloads","issues_url":"https://api.github.com/repos/3scale/porta/issues{/number}","pulls_url":"https://api.github.com/repos/3scale/porta/pulls{/number}","milestones_url":"https://api.github.com/repos/3scale/porta/milestones{/number}","notifications_url":"https://api.github.com/repos/3scale/porta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/3scale/porta/labels{/name}","releases_url":"https://api.github.com/repos/3scale/porta/releases{/id}","deployments_url":"https://api.github.com/repos/3scale/porta/deployments","created_at":"2018-09-18T16:03:13Z","updated_at":"2018-12-11T11:02:43Z","pushed_at":"2018-12-11T11:08:51Z","git_url":"git://github.com/3scale/porta.git","ssh_url":"git@github.com:3scale/porta.git","clone_url":"https://github.com/3scale/porta.git","svn_url":"https://github.com/3scale/porta","homepage":"","size":36309,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":4,"open_issues":34,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/3scale/porta/pulls/8"},"html":{"href":"https://github.com/3scale/porta/pull/8"},"issue":{"href":"https://api.github.com/repos/3scale/porta/issues/8"},"comments":{"href":"https://api.github.com/repos/3scale/porta/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/3scale/porta/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/3scale/porta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/3scale/porta/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/3scale/porta/statuses/f1f94056dff9aad199ba875f8b312fc632adc438"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"hallelujah"}}