DEV: Drop chat_uploads table and model and remove old references (#20926)

Followup to 0924f874bd9aca3515e17d0d084a35058e9d5757,
we migrated Chat::Upload records to UploadReference records
there and have not been making new Chat::Upload records
for some time, we can now delete the model and table.
This commit is contained in:
Martin Brennan
2023-04-04 09:13:39 +10:00
committed by GitHub
parent 858b1ccc51
commit c00d17535f
10 changed files with 29 additions and 144 deletions

View File

@ -44,7 +44,6 @@ module Jobs
# if the uploads are not used anywhere else they will be deleted
# by the CleanUpUploads job in core
::DB.exec("DELETE FROM chat_uploads WHERE chat_message_id IN (#{message_ids.join(",")})")
::UploadReference.where(
target_id: message_ids,
target_type: ::Chat::Message.sti_name,

View File

@ -60,11 +60,6 @@ module Chat
CLASS_MAPPING.invert.fetch(self) || super
end
# TODO (martin) Remove this when we drop the ChatUpload table
has_many :chat_uploads,
dependent: :destroy,
class_name: "Chat::Upload",
foreign_key: :chat_message_id
has_one :chat_webhook_event,
dependent: :destroy,
class_name: "Chat::WebhookEvent",

View File

@ -1,32 +0,0 @@
# frozen_string_literal: true
# TODO (martin) DEPRECATED: Remove this model once UploadReference has been
# in place for a couple of months, 2023-04-01
#
# NOTE: Do not use this model anymore, chat messages are linked to uploads via
# the UploadReference table now, just like everything else.
module Chat
class Upload < ActiveRecord::Base
self.table_name = "chat_uploads"
belongs_to :chat_message, class_name: "Chat::Message"
belongs_to :upload
deprecate *public_instance_methods(false)
end
end
# == Schema Information
#
# Table name: chat_uploads
#
# id :bigint not null, primary key
# chat_message_id :integer not null
# upload_id :integer not null
# created_at :datetime not null
# updated_at :datetime not null
#
# Indexes
#
# index_chat_uploads_on_chat_message_id_and_upload_id (chat_message_id,upload_id) UNIQUE
#