mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 18:12:46 +08:00
Follow-up for 89efcfcf
to properly fix nested arrays
This commit is contained in:
parent
f364317625
commit
afe2be4f62
|
@ -4,20 +4,20 @@ 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}").values.map { |s| s.sub("%{count}", "\\d+") }
|
||||
|
||||
%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
|
||||
|
||||
sql = <<~SQL
|
||||
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 ')}
|
||||
)
|
||||
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
|
||||
|
||||
execute sql
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user