2015-07-29 12:20:35 -04:00
|
|
|
class MigrateAutoClosePosts < ActiveRecord::Migration
|
|
|
|
def up
|
2015-11-19 16:36:59 -05:00
|
|
|
I18n.overrides_disabled do
|
2015-11-14 16:11:22 -05:00
|
|
|
strings = []
|
|
|
|
%w(days hours lastpost_days lastpost_hours lastpost_minutes).map do |k|
|
|
|
|
strings << I18n.t("topic_statuses.autoclosed_enabled_#{k}.one")
|
|
|
|
strings << I18n.t("topic_statuses.autoclosed_enabled_#{k}.other").sub("%{count}", "\\d+")
|
|
|
|
end
|
2015-07-29 12:20:35 -04:00
|
|
|
|
2015-11-14 16:11:22 -05:00
|
|
|
sql = "UPDATE posts SET action_code = 'autoclosed.enabled', post_type = 3 "
|
|
|
|
sql << "WHERE post_type = 2 AND ("
|
2017-07-27 21:20:09 -04:00
|
|
|
sql << strings.map { |s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(' OR ')
|
2015-11-14 16:11:22 -05:00
|
|
|
sql << ")"
|
2015-07-29 12:20:35 -04:00
|
|
|
|
2015-11-14 16:11:22 -05:00
|
|
|
execute sql
|
|
|
|
end
|
2015-07-29 12:20:35 -04:00
|
|
|
end
|
|
|
|
end
|