discourse/db/migrate/20160112025852_remove_users_from_topic_allowed_users.rb
Sam Saffron 30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00

23 lines
619 B
Ruby

# frozen_string_literal: true
class RemoveUsersFromTopicAllowedUsers < ActiveRecord::Migration[4.2]
# historically we added admins automatically to a message if they
# responded, despite them being in the group the message is targetted at
# this causes inbox bloat for pretty much no reason
def up
sql = <<SQL
DELETE FROM topic_allowed_users tu
USING topic_allowed_groups tg
JOIN group_users gu ON gu.group_id = tg.group_id
WHERE tu.user_id = gu.user_id AND tg.topic_id = tu.topic_id
SQL
execute sql
end
def down
# can not be reversed but can be replayed if needed
end
end