From afe2be4f622285d43ed10c92be0b4b708f689adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 23 Jul 2019 10:29:18 +0200 Subject: [PATCH] Follow-up for 89efcfcf to properly fix nested arrays --- ...20150729150523_migrate_auto_close_posts.rb | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/db/migrate/20150729150523_migrate_auto_close_posts.rb b/db/migrate/20150729150523_migrate_auto_close_posts.rb index 7c6664aa312..c487191d18a 100644 --- a/db/migrate/20150729150523_migrate_auto_close_posts.rb +++ b/db/migrate/20150729150523_migrate_auto_close_posts.rb @@ -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