From 4edf5213dcea48be7384042d960603628ae44b54 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sun, 19 May 2019 13:49:31 +0200 Subject: Add post-deployment migration script to delete public-boosts-of-private-toots (#10783) --- ...190519130537_remove_boosts_widening_audience.rb | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 db/post_migrate/20190519130537_remove_boosts_widening_audience.rb (limited to 'db/post_migrate') diff --git a/db/post_migrate/20190519130537_remove_boosts_widening_audience.rb b/db/post_migrate/20190519130537_remove_boosts_widening_audience.rb new file mode 100644 index 000000000..d2d924239 --- /dev/null +++ b/db/post_migrate/20190519130537_remove_boosts_widening_audience.rb @@ -0,0 +1,23 @@ +class RemoveBoostsWideningAudience < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + public_boosts = Status.find_by_sql(<<-SQL) + SELECT boost.id + FROM statuses AS boost + LEFT JOIN statuses AS boosted ON boost.reblog_of_id = boosted.id + WHERE + boost.id > 101746055577600000 + AND (boost.local = TRUE OR boost.uri IS NULL) + AND boost.visibility IN (0, 1) + AND boost.reblog_of_id IS NOT NULL + AND boosted.visibility = 2 + SQL + + RemovalWorker.push_bulk(public_boosts.pluck(:id)) + end + + def down + raise ActiveRecord::IrreversibleMigration + end +end -- cgit