discourse/db/migrate/20150728210202_migrate_old_moderator_posts.rb
Robin Ward 810a069cfd FIX: Couldn't migrate database from nothing due to I18n
Since I18n has a DB backend now, I've introduced a helper we can use to
skip overrides in certain situations. Otherwise migration from empty
databases was broken.
2015-11-14 16:12:09 -05:00

21 lines
706 B
Ruby

class MigrateOldModeratorPosts < ActiveRecord::Migration
def migrate_key(action_code)
I18n.backend.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