@ -20,6 +20,7 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
defup
if$stdout.isatty
say''
say'WARNING: This migration may take a *long* time for large instances'
say'It will *not* lock tables for any significant time, but it may run'
@ -34,6 +35,7 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
say"Continuing in #{i} second#{i==1?'':'s'}...",true
sleep1
end
end
duplicates=Account.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM accounts GROUP BY lower(username), lower(domain) HAVING count(*) > 1').to_hash