diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-19 00:37:38 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2017-09-19 00:39:52 +0200 |
commit | 05a8f401c20e2a0b35360544aba12905239cc369 (patch) | |
tree | f85865a690e62e59725118f413ae157e7a736ba3 /app/models/environment.rb | |
parent | 0223d84e797c914542882646c4faa97760c1a21c (diff) | |
download | gitlab-ce-05a8f401c20e2a0b35360544aba12905239cc369.tar.gz |
Reorganize indexes for the "deployments" tablereoganize-deployment-indexes
This removes the need for a default scope that adds a "WHERE project_id
= X" clause. This commit also includes an additional index for
Environment#last_deployment, ensuring this query uses just an index scan
instead of also applying a Filter.
Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36877
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 44e39e21442..b6868ccbe8f 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -6,9 +6,7 @@ class Environment < ActiveRecord::Base belongs_to :project, required: true, validate: true - has_many :deployments, - -> (env) { where(project_id: env.project_id) }, - dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :deployments, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_one :last_deployment, -> { order('deployments.id DESC') }, class_name: 'Deployment' |