mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
FIX: Delete related search data when record has been deleted.
This commit is contained in:
parent
490939a1c9
commit
ecc799ab56
@ -47,6 +47,8 @@ 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? },
|
||||
|
@ -52,6 +52,7 @@ 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"
|
||||
|
||||
|
@ -39,6 +39,8 @@ 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
|
||||
|
||||
|
@ -224,7 +224,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
|
||||
has_one :topic_search_data, dependent: :delete
|
||||
has_one :topic_embed, dependent: :destroy
|
||||
|
||||
belongs_to :image_upload, class_name: 'Upload'
|
||||
|
@ -48,6 +48,7 @@ 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user