Skip to content

A platform for community discussion. Free, open, simple.

another check to avoid unique index error in discourse_merger.rb

Neil Lalonde2786c793547e
diff --git a/script/bulk_import/discourse_merger.rb b/script/bulk_import/discourse_merger.rb
index 295d353b65a..03c0a702561 100644
--- a/script/bulk_import/discourse_merger.rb
+++ b/script/bulk_import/discourse_merger.rb
@@ -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