DEV: Use UploadReference instead of ChatUpload in chat (#19947)

We've had the UploadReference table for some time now in core,
but it was added after ChatUpload was and chat was just never
moved over to this new system.

This commit changes all chat code dealing with uploads to create/
update/delete/query UploadReference records instead of ChatUpload
records for consistency. At a later date we will drop the ChatUpload
table, but for now keeping it for data backup.

The migration + post migration are the same, we need both in case
any chat uploads are added/removed during deploy.
This commit is contained in:
Martin Brennan
2023-01-24 13:28:21 +10:00
committed by GitHub
parent ac4ee1a3d4
commit 0924f874bd
21 changed files with 286 additions and 103 deletions

View File

@ -372,14 +372,6 @@ after_initialize do
end
end
if respond_to?(:register_upload_unused)
register_upload_unused do |uploads|
uploads.joins("LEFT JOIN chat_uploads cu ON cu.upload_id = uploads.id").where(
"cu.upload_id IS NULL",
)
end
end
if respond_to?(:register_upload_in_use)
register_upload_in_use do |upload|
ChatMessage.where(