From cbe1dd8ec73197f69cd113fdf3fd87096951cfa1 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 9 Jul 2020 10:08:04 +0800 Subject: [PATCH] Revert "FIX: Delete related search data when record has been deleted." This reverts commit ecc799ab56a0e64668d347c2426b8501fe17b82c. This commit does not fix anything because we've always been deleting records in `Searchable`. --- app/models/category.rb | 2 -- app/models/post.rb | 1 - app/models/tag.rb | 2 -- app/models/topic.rb | 2 +- app/models/user.rb | 1 - 5 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/models/category.rb b/app/models/category.rb index cfd9de5556d..cb51a03cc48 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -47,8 +47,6 @@ class Category < ActiveRecord::Base has_and_belongs_to_many :web_hooks - has_one :category_search_data, dependent: :delete - validates :user_id, presence: true validates :name, if: Proc.new { |c| c.new_record? || c.will_save_change_to_name? }, diff --git a/app/models/post.rb b/app/models/post.rb index de9bb44f4ef..a9880a8d26d 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -52,7 +52,6 @@ class Post < ActiveRecord::Base has_many :revisions, -> { order(:number) }, foreign_key: :post_id, class_name: 'PostRevision' has_many :user_actions, foreign_key: :target_post_id - has_one :post_search_data, dependent: :delete belongs_to :image_upload, class_name: "Upload" diff --git a/app/models/tag.rb b/app/models/tag.rb index 7b18643c44a..6ff6afe6091 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -39,8 +39,6 @@ class Tag < ActiveRecord::Base belongs_to :target_tag, class_name: "Tag", optional: true has_many :synonyms, class_name: "Tag", foreign_key: "target_tag_id", dependent: :destroy - has_one :tag_search_data, dependent: :delete - after_save :index_search after_save :update_synonym_associations diff --git a/app/models/topic.rb b/app/models/topic.rb index 7ee0ea40715..06446ca588b 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -233,7 +233,7 @@ class Topic < ActiveRecord::Base has_one :user_warning has_one :first_post, -> { where post_number: 1 }, class_name: 'Post' - has_one :topic_search_data, dependent: :delete + has_one :topic_search_data has_one :topic_embed, dependent: :destroy belongs_to :image_upload, class_name: 'Upload' diff --git a/app/models/user.rb b/app/models/user.rb index 66916d6d52d..acbcdb0c18c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -48,7 +48,6 @@ class User < ActiveRecord::Base has_one :anonymous_user_master, class_name: 'AnonymousUser', dependent: :destroy has_one :anonymous_user_shadow, ->(record) { where(active: true) }, foreign_key: :master_user_id, class_name: 'AnonymousUser', dependent: :destroy has_one :invited_user, dependent: :destroy - has_one :user_search_data, dependent: :delete # delete all is faster but bypasses callbacks has_many :bookmarks, dependent: :delete_all