fix: Notification page breakages (#5236)

- Remove the cascading foreign key indexes
- Add migration to clean up existing objects

fixes: #4285
This commit is contained in:
Sojan Jose
2022-08-10 13:46:46 +02:00
committed by GitHub
parent 12b6fb211a
commit 74fdfffe08
23 changed files with 93 additions and 115 deletions

View File

@@ -37,12 +37,6 @@
# index_conversations_on_status_and_account_id (status,account_id)
# index_conversations_on_team_id (team_id)
#
# Foreign Keys
#
# fk_rails_... (campaign_id => campaigns.id) ON DELETE => cascade
# fk_rails_... (contact_inbox_id => contact_inboxes.id) ON DELETE => cascade
# fk_rails_... (team_id => teams.id) ON DELETE => cascade
#
class Conversation < ApplicationRecord
include Labelable
@@ -88,7 +82,7 @@ class Conversation < ApplicationRecord
has_many :mentions, dependent: :destroy_async
has_many :messages, dependent: :destroy_async, autosave: true
has_one :csat_survey_response, dependent: :destroy_async
has_many :notifications, as: :primary_actor, dependent: :destroy
has_many :notifications, as: :primary_actor, dependent: :destroy_async
before_save :ensure_snooze_until_reset
before_create :mark_conversation_pending_if_bot