FIX: Migrations tried to change frozen string

FIX: Migrations tried to change frozen string

Also, makes the migration work with locales which use more than just the “one” and “other” keys.

diff --git a/db/migrate/20131022045114_add_uncategorized_category.rb b/db/migrate/20131022045114_add_uncategorized_category.rb
index 14b17d1..cb362fb 100644
--- a/db/migrate/20131022045114_add_uncategorized_category.rb
+++ b/db/migrate/20131022045114_add_uncategorized_category.rb
@@ -4,7 +4,7 @@ class AddUncategorizedCategory < ActiveRecord::Migration[4.2]
   def up
 
     result = execute "SELECT 1 FROM categories WHERE lower(name) = 'uncategorized'"
-    name = 'Uncategorized'
+    name = +'Uncategorized'
     if result.count > 0
       name << SecureRandom.hex
     end
diff --git a/db/migrate/20150729150523_migrate_auto_close_posts.rb b/db/migrate/20150729150523_migrate_auto_close_posts.rb
index 5b48992..78508d7 100644
--- a/db/migrate/20150729150523_migrate_auto_close_posts.rb
+++ b/db/migrate/20150729150523_migrate_auto_close_posts.rb
@@ -5,14 +5,17 @@ class MigrateAutoClosePosts < ActiveRecord::Migration[4.2]
     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+")
+        strings << I18n.t("topic_statuses.autoclosed_enabled_#{k}").values.map { |s| s.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 + ")"
+      sql = <<~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
 
       execute sql
     end

GitHub sha: a8cdd685

1 Like

This commit has been mentioned on Discourse Meta. There might be relevant details there:

1 Like

Follow-up for a8cdd685 to fix nested array