2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Ci
|
2021-10-27 15:23:28 +05:30
|
|
|
class BuildNeed < Ci::ApplicationRecord
|
2020-07-28 23:09:34 +05:30
|
|
|
include BulkInsertSafe
|
2021-06-08 01:23:25 +05:30
|
|
|
include IgnorableColumns
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
belongs_to :build, class_name: "Ci::Processable", foreign_key: :build_id, inverse_of: :needs
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
validates :build, presence: true
|
|
|
|
validates :name, presence: true, length: { maximum: 128 }
|
2021-04-17 20:07:23 +05:30
|
|
|
validates :optional, inclusion: { in: [true, false] }
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
scope :scoped_build, -> { where('ci_builds.id=ci_build_needs.build_id') }
|
2020-01-01 13:55:28 +05:30
|
|
|
scope :artifacts, -> { where(artifacts: true) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
# TODO: Remove once build_id_convert_to_bigint is not an "ignored" column anymore (see .ignore_columns above)
|
|
|
|
# There is a database-side trigger to populate this column. This is unexpected in the context
|
|
|
|
# of cloning an instance, e.g. when retrying the job. Hence we exclude the ignored column explicitly here.
|
|
|
|
def attributes
|
|
|
|
super.except('build_id_convert_to_bigint')
|
|
|
|
end
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
end
|