discourse/db/migrate/20150728210202_migrate_old_moderator_posts.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

24 lines
734 B
Ruby

# frozen_string_literal: true
class MigrateOldModeratorPosts < ActiveRecord::Migration[4.2]
def migrate_key(action_code)
I18n.overrides_disabled do
text = I18n.t("topic_statuses.#{action_code.gsub('.', '_')}")
execute "UPDATE posts SET action_code = '#{action_code}', raw = '', cooked = '', post_type = 3 where post_type = 2 AND raw = #{ActiveRecord::Base.connection.quote(text)}"
end
end
def up
migrate_key('closed.enabled')
migrate_key('closed.disabled')
migrate_key('archived.enabled')
migrate_key('archived.disabled')
migrate_key('pinned.enabled')
migrate_key('pinned.disabled')
migrate_key('pinned_globally.enabled')
migrate_key('pinned_globally.disabled')
end
end