scope:without_muted,->(account){joins("LEFT OUTER JOIN announcement_mutes ON announcement_mutes.announcement_id = announcements.id AND announcement_mutes.account_id = #{account.id}").where('announcement_mutes.id IS NULL')}
scope:without_muted,->(account){joins("LEFT OUTER JOIN announcement_mutes ON announcement_mutes.announcement_id = announcements.id AND announcement_mutes.account_id = #{account.id}").where('announcement_mutes.id IS NULL')}
@ -20,6 +20,7 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
disable_ddl_transaction!
defup
defup
if$stdout.isatty
say''
say''
say'WARNING: This migration may take a *long* time for large instances'
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'
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
say"Continuing in #{i} second#{i==1?'':'s'}...",true
sleep1
sleep1
end
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
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