2019-05-03 06:17:27 +08:00
# frozen_string_literal: true
2017-08-31 12:06:56 +08:00
class MigrateOldModeratorPosts < ActiveRecord :: Migration [ 4 . 2 ]
2015-07-29 05:35:33 +08:00
def migrate_key ( action_code )
2015-11-20 05:36:59 +08:00
I18n . overrides_disabled do
2015-11-15 05:11:22 +08:00
text = I18n . t ( " topic_statuses. #{ action_code . gsub ( " . " , " _ " ) } " )
2015-07-29 05:35:33 +08:00
2015-11-15 05:11:22 +08:00
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
2015-07-29 05:35:33 +08:00
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