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

@ -310,9 +310,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
if !post.raw[html]
post.raw << "\n\n" << html
post.save!
unless PostUpload.where(post: post, upload: upload).exists?
PostUpload.create!(post: post, upload: upload)
end
UploadReference.ensure_exist!(upload_ids: [upload.id], target: post)
end
end
end
@ -360,9 +358,7 @@ class ImportScripts::Bbpress < ImportScripts::Base
if !post.raw[html]
post.raw << "\n\n" << html
post.save!
unless PostUpload.where(post: post, upload: upload).exists?
PostUpload.create!(post: post, upload: upload)
end
UploadReference.ensure_exist!(upload_ids: [upload.id], target: post)
end
end
end