mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
24 lines
657 B
Ruby
24 lines
657 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).each do |k|
|
|
I18n.t("topic_statuses.autoclosed_enabled_#{k}").values.each do |s|
|
|
strings << s.sub("%{count}", "\\d+")
|
|
end
|
|
end
|
|
|
|
execute <<~SQL
|
|
UPDATE posts
|
|
SET action_code = 'autoclosed.enabled'
|
|
, post_type = 3
|
|
WHERE post_type = 2
|
|
AND (#{strings.map { |s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(' OR ')})
|
|
SQL
|
|
end
|
|
end
|
|
end
|