discourse/db/migrate/20180223222415_remove_censored_pattern_site_setting.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

22 lines
592 B
Ruby

# frozen_string_literal: true
class RemoveCensoredPatternSiteSetting < ActiveRecord::Migration[5.1]
def up
execute <<~SQL
INSERT INTO user_histories
(action, acting_user_id, subject, previous_value,
new_value, admin_only, created_at, updated_at)
SELECT 3, -1, 'censored_pattern', value, '', true, now(), now()
FROM site_settings
WHERE name = 'censored_pattern'
AND value != ''
SQL
execute "DELETE FROM site_settings WHERE name = 'censored_pattern'"
end
def down
raise ActiveRecord::IrreversibleMigration
end
end