diff options
author | Jan Provaznik <jprovaznik@gitlab.com> | 2019-09-06 12:54:58 +0300 |
---|---|---|
committer | Jan Provaznik <jprovaznik@gitlab.com> | 2019-09-07 07:43:17 +0300 |
commit | f2754e416e16c1b56810b835505346c295578c7a (patch) | |
tree | 42867740b585563f6569e5b9a46071c67466e5bc /app/models | |
parent | 093858adc76f893c35b0bcf25127c3f229a7bcb6 (diff) |
Use delete_all for deleting events
Because we don't have any destroy callbacks (or other logic
triggered on event destroy), there is no reason for deleting events
inefficiently one by one, instead we can use :delete_all.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | app/models/merge_request.rb | 2 | ||||
-rw-r--r-- | app/models/milestone.rb | 2 | ||||
-rw-r--r-- | app/models/note.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 2 |
5 files changed, 5 insertions, 5 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 75d4fc8c1c5..7c5a139ab55 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -31,7 +31,7 @@ class Issue < ApplicationRecord has_internal_id :iid, scope: :project, init: ->(s) { s&.project&.issues&.maximum(:iid) } - has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :merge_requests_closing_issues, class_name: 'MergeRequestsClosingIssues', diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 95daa48d4bc..901ebcf249f 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -54,7 +54,7 @@ class MergeRequest < ApplicationRecord belongs_to :head_pipeline, foreign_key: "head_pipeline_id", class_name: "Ci::Pipeline" - has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :merge_requests_closing_issues, class_name: 'MergeRequestsClosingIssues', diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 915978d37b8..7f46e5faf1a 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -37,7 +37,7 @@ class Milestone < ApplicationRecord has_many :issues has_many :labels, -> { distinct.reorder('labels.title') }, through: :issues has_many :merge_requests - has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent scope :of_projects, ->(ids) { where(project_id: ids) } scope :of_groups, ->(ids) { where(group_id: ids) } diff --git a/app/models/note.rb b/app/models/note.rb index 0d024b0a25c..5bd3a7f969a 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -78,7 +78,7 @@ class Note < ApplicationRecord # suggestions.delete_all calls has_many :suggestions, -> { order(:relative_order) }, inverse_of: :note, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent - has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_one :system_note_metadata has_one :note_diff_file, inverse_of: :diff_note, foreign_key: :diff_note_id diff --git a/app/models/user.rb b/app/models/user.rb index 67d730e2fa3..5f109feb96a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -131,7 +131,7 @@ class User < ApplicationRecord has_many :notes, dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent has_many :issues, dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent has_many :merge_requests, dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent - has_many :events, dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent + has_many :events, dependent: :delete_all, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent has_many :releases, dependent: :nullify, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent has_many :subscriptions, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent |