another check to avoid unique index error in discourse_merger.rb

This commit is contained in:
Neil Lalonde 2018-07-16 13:34:27 -04:00
parent bd51cd52cd
commit 2786c79354
1 changed files with 3 additions and 0 deletions

View File

@ -546,6 +546,9 @@ class BulkImport::DiscourseMerger < BulkImport::Base
return nil if @imported_post_uploads[post_upload['post_id']] == post_upload['upload_id']
@imported_post_uploads[post_upload['post_id']] = post_upload['upload_id']
# ...and there are still duplicates. So try this:
return nil if PostUpload.where(post_id: post_upload['post_id'], upload_id: post_upload['upload_id']).exists?
post_upload
end