mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 12:43:42 +08:00
30990006a9
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
21 lines
679 B
Ruby
21 lines
679 B
Ruby
# frozen_string_literal: true
|
|
|
|
class MigrateAutoClosePosts < ActiveRecord::Migration[4.2]
|
|
def up
|
|
I18n.overrides_disabled do
|
|
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
|
|
|
|
sql = "UPDATE posts SET action_code = 'autoclosed.enabled', post_type = 3 "
|
|
sql + "WHERE post_type = 2 AND ("
|
|
sql + strings.map { |s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(' OR ')
|
|
sql + ")"
|
|
|
|
execute sql
|
|
end
|
|
end
|
|
end
|