diff options
author | Ondřej Hruška <ondra@ondrovo.com> | 2017-07-17 20:03:57 +0200 |
---|---|---|
committer | Ondřej Hruška <ondra@ondrovo.com> | 2017-07-17 20:03:57 +0200 |
commit | c727eae4412ac9e4f1bafdc68fe89dcd46d602ca (patch) | |
tree | ee7ce8662f6a91c87cf46bf6de70dae66556c0d0 /lib | |
parent | d0aad1ac854eaa53f9b7d38cc8dd90e289790629 (diff) | |
parent | 681c33d1f4c395742918eb66f2db979b0d628118 (diff) |
Updated from tootsuite
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/mastodon.rake | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 010139e91..bceeeaf01 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -232,9 +232,16 @@ namespace :mastodon do task prepare_for_foreign_keys: :environment do # All the deletes: ActiveRecord::Base.connection.execute('DELETE FROM statuses USING statuses s LEFT JOIN accounts a ON a.id = s.account_id WHERE statuses.id = s.id AND a.id IS NULL') - ActiveRecord::Base.connection.execute('DELETE FROM account_domain_blocks USING account_domain_blocks adb LEFT JOIN accounts a ON a.id = adb.account_id WHERE account_domain_blocks.id = adb.id AND a.id IS NULL') - ActiveRecord::Base.connection.execute('DELETE FROM conversation_mutes USING conversation_mutes cm LEFT JOIN accounts a ON a.id = cm.account_id WHERE conversation_mutes.id = cm.id AND a.id IS NULL') - ActiveRecord::Base.connection.execute('DELETE FROM conversation_mutes USING conversation_mutes cm LEFT JOIN conversations c ON c.id = cm.conversation_id WHERE conversation_mutes.id = cm.id AND c.id IS NULL') + + if ActiveRecord::Base.connection.table_exists? :account_domain_blocks + ActiveRecord::Base.connection.execute('DELETE FROM account_domain_blocks USING account_domain_blocks adb LEFT JOIN accounts a ON a.id = adb.account_id WHERE account_domain_blocks.id = adb.id AND a.id IS NULL') + end + + if ActiveRecord::Base.connection.table_exists? :conversation_mutes + ActiveRecord::Base.connection.execute('DELETE FROM conversation_mutes USING conversation_mutes cm LEFT JOIN accounts a ON a.id = cm.account_id WHERE conversation_mutes.id = cm.id AND a.id IS NULL') + ActiveRecord::Base.connection.execute('DELETE FROM conversation_mutes USING conversation_mutes cm LEFT JOIN conversations c ON c.id = cm.conversation_id WHERE conversation_mutes.id = cm.id AND c.id IS NULL') + end + ActiveRecord::Base.connection.execute('DELETE FROM favourites USING favourites f LEFT JOIN accounts a ON a.id = f.account_id WHERE favourites.id = f.id AND a.id IS NULL') ActiveRecord::Base.connection.execute('DELETE FROM favourites USING favourites f LEFT JOIN statuses s ON s.id = f.status_id WHERE favourites.id = f.id AND s.id IS NULL') ActiveRecord::Base.connection.execute('DELETE FROM blocks USING blocks b LEFT JOIN accounts a ON a.id = b.account_id WHERE blocks.id = b.id AND a.id IS NULL') |