diff options
Diffstat (limited to 'app/models/ci/runner_machine_build.rb')
-rw-r--r-- | app/models/ci/runner_machine_build.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/ci/runner_machine_build.rb b/app/models/ci/runner_machine_build.rb new file mode 100644 index 00000000000..d4f2c403337 --- /dev/null +++ b/app/models/ci/runner_machine_build.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Ci + class RunnerMachineBuild < Ci::ApplicationRecord + include Ci::Partitionable + + self.table_name = :p_ci_runner_machine_builds + self.primary_key = :build_id + + partitionable scope: :build, partitioned: true + + belongs_to :build, inverse_of: :runner_machine_build, class_name: 'Ci::Build' + belongs_to :runner_machine, inverse_of: :runner_machine_builds, class_name: 'Ci::RunnerMachine' + + validates :build, presence: true + validates :runner_machine, presence: true + + scope :for_build, ->(build_id) { where(build_id: build_id) } + + def self.pluck_build_id_and_runner_machine_id + select(:build_id, :runner_machine_id) + .pluck(:build_id, :runner_machine_id) + .to_h + end + end +end |