diff options
Diffstat (limited to 'app/models/ci/stage.rb')
-rw-r--r-- | app/models/ci/stage.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index f03d1e96a4b..46a9e3f6494 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -2,22 +2,31 @@ module Ci class Stage < Ci::ApplicationRecord + include Ci::Partitionable include Importable include Ci::HasStatus include Gitlab::OptimisticLocking include Presentable + partitionable scope: :pipeline + enum status: Ci::HasStatus::STATUSES_ENUM belongs_to :project belongs_to :pipeline - has_many :statuses, class_name: 'CommitStatus', foreign_key: :stage_id - has_many :latest_statuses, -> { ordered.latest }, class_name: 'CommitStatus', foreign_key: :stage_id - has_many :retried_statuses, -> { ordered.retried }, class_name: 'CommitStatus', foreign_key: :stage_id - has_many :processables, class_name: 'Ci::Processable', foreign_key: :stage_id - has_many :builds, foreign_key: :stage_id - has_many :bridges, foreign_key: :stage_id + has_many :statuses, class_name: 'CommitStatus', foreign_key: :stage_id, inverse_of: :ci_stage + has_many :latest_statuses, -> { ordered.latest }, + class_name: 'CommitStatus', + foreign_key: :stage_id, + inverse_of: :ci_stage + has_many :retried_statuses, -> { ordered.retried }, + class_name: 'CommitStatus', + foreign_key: :stage_id, + inverse_of: :ci_stage + has_many :processables, class_name: 'Ci::Processable', foreign_key: :stage_id, inverse_of: :ci_stage + has_many :builds, foreign_key: :stage_id, inverse_of: :ci_stage + has_many :bridges, foreign_key: :stage_id, inverse_of: :ci_stage scope :ordered, -> { order(position: :asc) } scope :in_pipelines, ->(pipelines) { where(pipeline: pipelines) } |