emails: add fix script to delete duplicate email addresses.

In the past it was possible for users to create multiple accounts with
the same email address. We had about 9000 such accounts. This removes
the email address from these accounts.

When multiple accounts have the same email address, the account that
visited the site last gets to keep the address.
This commit is contained in:
evazion
2022-10-02 23:50:54 -05:00
parent 21747e1f8e
commit 86e69e3401
2 changed files with 92 additions and 0 deletions

View File

@@ -149,6 +149,7 @@ class User < ApplicationRecord
scope :deleted, -> { where("name ~ 'user_[0-9]+~*'") }
scope :undeleted, -> { where("name !~ 'user_[0-9]+~*'") }
scope :admins, -> { where(level: Levels::ADMIN) }
scope :banned, -> { bit_prefs_match(:is_banned, true) }
scope :has_blacklisted_tag, ->(name) { where_regex(:blacklisted_tags, "(^| )[~-]?#{Regexp.escape(name)}( |$)", flags: "ni") }
scope :has_private_favorites, -> { bit_prefs_match(:enable_private_favorites, true) }