about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-10-07 04:14:36 +0200
committerGitHub <noreply@github.com>2019-10-07 04:14:36 +0200
commitb5be067c88151f75e09fc7d8b558ad4ccd51867b (patch)
tree1fea7f1493c101230a48cb71fc6e34bfb9904010 /db/migrate
parent8386d9ec1001f8a938224190e518db054751b5a9 (diff)
Fix existing user records with now-renamed `pt` locale (#12092)
Fix #12082
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20191007013357_update_pt_locales.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/db/migrate/20191007013357_update_pt_locales.rb b/db/migrate/20191007013357_update_pt_locales.rb
new file mode 100644
index 000000000..b7288d38a
--- /dev/null
+++ b/db/migrate/20191007013357_update_pt_locales.rb
@@ -0,0 +1,11 @@
+class UpdatePtLocales < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    User.where(locale: 'pt').in_batches.update_all(locale: 'pt-PT')
+  end
+
+  def down
+    User.where(locale: 'pt-PT').in_batches.update_all(locale: 'pt')
+  end
+end