Comparison was downcasing only one side, therefore if previously
existing account had a non-lowercase spelling, it would be ignored
when checking for duplicates.
New rake task `mastodon:maintenance:find_duplicate_usernames` will
help find constraint violations that might have occured from the
presence of this bug.
Bump version to 2.3.3
desc'Find case-insensitive username duplicates of local users'
taskfind_duplicate_usernames::environmentdo
includeRoutingHelper
disable_log_stdout!
duplicate_masters=Account.find_by_sql('SELECT * FROM accounts WHERE id IN (SELECT min(id) FROM accounts WHERE domain IS NULL GROUP BY lower(username) HAVING count(*) > 1)')
pastel=Pastel.new
duplicate_masters.eachdo|account|
putspastel.yellow("First of their name: ")+pastel.bold(account.username)+" (#{admin_account_url(account.id)})"