Wrong exception class: ActiveRecord::RecordNotUnique, not PG::UniqueViolation (#7688)
* Wrong exception class: ActiveRecord::RecordNotUnique, not PG::UniqueViolation It's completely not obvious but PG::UniqueViolation is just a string inside the exception message, not the actual class of the exception * Favourite does not have target_account_id
This commit is contained in:
parent
19b4c666f7
commit
fb1ae0152d
|
@ -73,15 +73,17 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
|
||||||
klass.where(account_id: duplicate_account.id).find_each do |record|
|
klass.where(account_id: duplicate_account.id).find_each do |record|
|
||||||
begin
|
begin
|
||||||
record.update_attribute(:account_id, main_account.id)
|
record.update_attribute(:account_id, main_account.id)
|
||||||
rescue PG::UniqueViolation
|
rescue ActiveRecord::RecordNotUnique
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
[Follow, FollowRequest, Block, Mute].each do |klass|
|
||||||
klass.where(target_account_id: duplicate_account.id).find_each do |record|
|
klass.where(target_account_id: duplicate_account.id).find_each do |record|
|
||||||
begin
|
begin
|
||||||
record.update_attribute(:target_account_id, main_account.id)
|
record.update_attribute(:target_account_id, main_account.id)
|
||||||
rescue PG::UniqueViolation
|
rescue ActiveRecord::RecordNotUnique
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue