Bladeren bron

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
master
Eugen Rochko 6 jaren geleden
committed by GitHub
bovenliggende
commit
fb1ae0152d
Geen bekende sleutel gevonden voor deze handtekening in de database GPG sleutel-ID: 4AEE18F83AFDEB23
1 gewijzigde bestanden met toevoegingen van 4 en 2 verwijderingen
  1. +4
    -2
      db/migrate/20180528141303_fix_accounts_unique_index.rb

+ 4
- 2
db/migrate/20180528141303_fix_accounts_unique_index.rb Bestand weergeven

@@ -73,15 +73,17 @@ class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
klass.where(account_id: duplicate_account.id).find_each do |record|
begin
record.update_attribute(:account_id, main_account.id)
rescue PG::UniqueViolation
rescue ActiveRecord::RecordNotUnique
next
end
end
end

[Follow, FollowRequest, Block, Mute].each do |klass|
klass.where(target_account_id: duplicate_account.id).find_each do |record|
begin
record.update_attribute(:target_account_id, main_account.id)
rescue PG::UniqueViolation
rescue ActiveRecord::RecordNotUnique
next
end
end


Laden…
Annuleren
Opslaan