discourse/db/migrate/20171110174413_rename_blocked_silence.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

35 lines
1.7 KiB
Ruby

# frozen_string_literal: true
class RenameBlockedSilence < ActiveRecord::Migration[5.1]
def setting(old, new)
execute "UPDATE site_settings SET name='#{new}' where name='#{old}'"
end
def up
add_column :users, :silenced, :boolean, default: false, null: false
execute "UPDATE users set silenced = blocked"
setting :notify_mods_when_user_blocked, :notify_mods_when_user_silenced
setting :auto_block_fast_typers_on_first_post, :auto_silence_fast_typers_on_first_post
setting :auto_block_fast_typers_max_trust_level, :auto_silence_fast_typers_max_trust_level
setting :auto_block_first_post_regex, :auto_silence_first_post_regex
setting :num_spam_flags_to_block_new_user, :num_spam_flags_to_silence_new_user
setting :num_users_to_block_new_user, :num_users_to_silence_new_user
setting :num_tl3_flags_to_block_new_user, :num_tl3_flags_to_silence_new_user
setting :num_tl3_users_to_block_new_user, :num_tl3_users_to_silence_new_user
end
def down
remove_column :users, :silenced
setting :notify_mods_when_user_silenced, :notify_mods_when_user_blocked
setting :auto_silence_fast_typers_on_first_post, :auto_block_fast_typers_on_first_post
setting :auto_silence_fast_typers_max_trust_level, :auto_block_fast_typers_max_trust_level
setting :auto_silence_first_post_regex, :auto_block_first_post_regex
setting :num_spam_flags_to_silence_new_user, :num_spam_flags_to_block_new_user
setting :num_users_to_silence_new_user, :num_users_to_block_new_user
setting :num_tl3_flags_to_silence_new_user, :num_tl3_flags_to_block_new_user
setting :num_tl3_users_to_silence_new_user, :num_tl3_users_to_block_new_user
end
end