Skip to content

A platform for community discussion. Free, open, simple.

Follow-up for 89efcfcf to properly fix nested arrays

Régis Hanolafe2be4f6222
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