about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2018-05-30 16:39:52 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-05-30 09:39:52 +0200
commit9130b3cda9cd460aa137e399a8b50880aba3bb63 (patch)
tree3f826708ca61534e6ede07cf3a37a5d1cb221355 /db
parenta16e06bbf584412c5a0f812da37fcd6e2c479d1a (diff)
Fix broken migrate (regression from #7658) (#7674)
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180528141303_fix_accounts_unique_index.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/db/migrate/20180528141303_fix_accounts_unique_index.rb b/db/migrate/20180528141303_fix_accounts_unique_index.rb
index 2e5eca814..92e490f9e 100644
--- a/db/migrate/20180528141303_fix_accounts_unique_index.rb
+++ b/db/migrate/20180528141303_fix_accounts_unique_index.rb
@@ -36,7 +36,7 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
 
   def deduplicate_account!(account_ids)
     accounts          = Account.where(id: account_ids).to_a
-    accounts          = account.first.local? ? accounts.sort_by(&:created_at) : accounts.sort_by(&:updated_at).reverse
+    accounts          = accounts.first.local? ? accounts.sort_by(&:created_at) : accounts.sort_by(&:updated_at).reverse
     reference_account = accounts.shift
 
     accounts.each do |other_account|
@@ -69,15 +69,19 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
     # to check for (and skip past) uniqueness errors
     [Follow, FollowRequest, Block, Mute].each do |klass|
       klass.where(account_id: duplicate_account.id).find_each do |record|
-        record.update(account_id: main_account.id)
-      rescue ActiveRecord::RecordNotUnique
-        next
+        begin
+          record.update(account_id: main_account.id)
+        rescue ActiveRecord::RecordNotUnique
+          next
+        end
       end
 
       klass.where(target_account_id: duplicate_account.id).find_each do |record|
-        record.update(target_account_id: main_account.id)
-      rescue ActiveRecord::RecordNotUnique
-        next
+        begin
+          record.update(target_account_id: main_account.id)
+        rescue ActiveRecord::RecordNotUnique
+          next
+        end
       end
     end
   end