{"action":"created","issue":{"url":"https://api.github.com/repos/tootsuite/mastodon/issues/7658","repository_url":"https://api.github.com/repos/tootsuite/mastodon","labels_url":"https://api.github.com/repos/tootsuite/mastodon/issues/7658/labels{/name}","comments_url":"https://api.github.com/repos/tootsuite/mastodon/issues/7658/comments","events_url":"https://api.github.com/repos/tootsuite/mastodon/issues/7658/events","html_url":"https://github.com/tootsuite/mastodon/pull/7658","id":327086156,"number":7658,"title":"Deduplicate accounts and make unique username/domain index case-insensitive","user":{"login":"Gargron","id":184731,"avatar_url":"https://avatars3.githubusercontent.com/u/184731?v=4","gravatar_id":"","url":"https://api.github.com/users/Gargron","html_url":"https://github.com/Gargron","followers_url":"https://api.github.com/users/Gargron/followers","following_url":"https://api.github.com/users/Gargron/following{/other_user}","gists_url":"https://api.github.com/users/Gargron/gists{/gist_id}","starred_url":"https://api.github.com/users/Gargron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gargron/subscriptions","organizations_url":"https://api.github.com/users/Gargron/orgs","repos_url":"https://api.github.com/users/Gargron/repos","events_url":"https://api.github.com/users/Gargron/events{/privacy}","received_events_url":"https://api.github.com/users/Gargron/received_events","type":"User","site_admin":false},"labels":[{"id":330102524,"url":"https://api.github.com/repos/tootsuite/mastodon/labels/bug","name":"bug","color":"c91910","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2018-05-28T17:39:35Z","updated_at":"2018-05-29T18:54:44Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/tootsuite/mastodon/pulls/7658","html_url":"https://github.com/tootsuite/mastodon/pull/7658","diff_url":"https://github.com/tootsuite/mastodon/pull/7658.diff","patch_url":"https://github.com/tootsuite/mastodon/pull/7658.patch"},"body":"> **Previously on Mastodon**: Username/domain uniqueness constraint exists, but is case-*sensitive*. Case-insensitive index also exists, but is not unique. Duplicates caused primarily by admins changing casing of usernames in database, and that one time we had a missing validation in Ruby for one short release.\r\n\r\nFix #6937\r\nFix #6837\r\nFix #6667\r\n\r\n1. Get all accounts with overlapping username/domain\r\n2. For each account:\r\n    1. Select most recently updated (used) one to be the reference account\r\n    2. Compare others against it\r\n        - If the public key is the same, it's definitely the same person, so they can be merged. Change attributions on owned associations to the reference account\r\n        - Delete the other account\r\n3. Re-create case-insensitive index with uniqueness constraint\r\n4. Remove now useless case-sensitive unique index\r\n\r\n> Damn, why do all those issues end in 7s. I just noticed."},"comment":{"url":"https://api.github.com/repos/tootsuite/mastodon/issues/comments/392897371","html_url":"https://github.com/tootsuite/mastodon/pull/7658#issuecomment-392897371","issue_url":"https://api.github.com/repos/tootsuite/mastodon/issues/7658","id":392897371,"user":{"login":"nightpool","id":233815,"avatar_url":"https://avatars2.githubusercontent.com/u/233815?v=4","gravatar_id":"","url":"https://api.github.com/users/nightpool","html_url":"https://github.com/nightpool","followers_url":"https://api.github.com/users/nightpool/followers","following_url":"https://api.github.com/users/nightpool/following{/other_user}","gists_url":"https://api.github.com/users/nightpool/gists{/gist_id}","starred_url":"https://api.github.com/users/nightpool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nightpool/subscriptions","organizations_url":"https://api.github.com/users/nightpool/orgs","repos_url":"https://api.github.com/users/nightpool/repos","events_url":"https://api.github.com/users/nightpool/events{/privacy}","received_events_url":"https://api.github.com/users/nightpool/received_events","type":"User","site_admin":false},"created_at":"2018-05-29T18:54:44Z","updated_at":"2018-05-29T18:54:44Z","author_association":"COLLABORATOR","body":"@Jarred-Sumner we can't change the type of the column at this point. Plus, we don't want the behavior citext gives here—if two accounts share the same name with different casing, we want to fail fast rather then running into nasty compatibility issues down the line when software that assumes they should be distinct ends up \"sharing\" the same account on our end."}}
{"actor":{"display_login":"nightpool"}}