diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-01-16 11:15:04 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-01-16 11:15:04 +0300 |
commit | 0de7ae34cdb06f72d5f674c056f28cd32c03bda3 (patch) | |
tree | 6fa53101590354b3703233d7b1ea8fe152b7896a /app/models | |
parent | 9e70ff345fa68d700b77b5939d34870ee61cb131 (diff) | |
parent | 0fd0000b8c1661930ce7f7427ad26a5081fbcd78 (diff) |
Merge branch 'sh-optimize-ci-build-project' into 'master'
Ensure CI pipelines and builds have the correction project associations
See merge request gitlab-org/gitlab-ce!16448
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/build.rb | 1 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 4 |
3 files changed, 4 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 6012dbba1b9..df67fb243ad 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -8,6 +8,7 @@ module Ci MissingDependenciesError = Class.new(StandardError) + belongs_to :project, inverse_of: :builds belongs_to :runner belongs_to :trigger_request belongs_to :erased_by, class_name: 'User' diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index d4690da3be6..d7153d7b816 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -7,7 +7,7 @@ module Ci include Presentable include Gitlab::OptimisticLocking - belongs_to :project + belongs_to :project, inverse_of: :pipelines belongs_to :user belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline' belongs_to :pipeline_schedule, class_name: 'Ci::PipelineSchedule' diff --git a/app/models/project.rb b/app/models/project.rb index 7ab7df4fdcd..d011b614c69 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -199,13 +199,13 @@ class Project < ActiveRecord::Base has_many :container_repositories, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :commit_statuses - has_many :pipelines, class_name: 'Ci::Pipeline' + has_many :pipelines, class_name: 'Ci::Pipeline', inverse_of: :project # Ci::Build objects store data on the file system such as artifact files and # build traces. Currently there's no efficient way of removing this data in # bulk that doesn't involve loading the rows into memory. As a result we're # still using `dependent: :destroy` here. - has_many :builds, class_name: 'Ci::Build', dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent + has_many :builds, class_name: 'Ci::Build', inverse_of: :project, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :build_trace_section_names, class_name: 'Ci::BuildTraceSectionName' has_many :runner_projects, class_name: 'Ci::RunnerProject' has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' |