DEV: Update importers from PostUpload to UploadReference (#23681)

Discourse stopped using PostUpload in 9db8f00b3d. Since then, these importers have been writing to the table, but any data was totally unused. This commit updates the easy cases to use UploadReference, and adds an error to the discourse_merger import script, which needs more significant work.
This commit is contained in:
David Taylor
2023-09-27 15:01:04 +01:00
committed by GitHub
parent fc2e92d423
commit 8a5d97ef3f
6 changed files with 10 additions and 16 deletions

View File

@ -270,10 +270,10 @@ class ImportScripts::Phorum < ImportScripts::Base
if !post.raw[html]
post.raw += "\n\n#{html}\n\n"
post.save!
if PostUpload.where(post: post, upload: upl_obj).exists?
if UploadReference.where(target: post, upload: upl_obj).exists?
puts "skipping creating uploaded for previously uploaded file #{upload["file_id"]}"
else
PostUpload.create!(post: post, upload: upl_obj)
UploadReference.ensure_exist!(upload_ids: [upl_obj.id], target: post)
end
# PostUpload.create!(post: post, upload: upl_obj) unless PostUpload.where(post: post, upload: upl_obj).exists?
else