aboutsummaryrefslogtreecommitdiff
path: root/app/models/mini_environment.rb
blob: c90d318bcf078613c908626cf0f66377cc277237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# == Schema Information
#
# Table name: mini_environments
#
#  id                     :integer          not null, primary key
#  name                   :string
#  created_at             :datetime         not null
#  updated_at             :datetime         not null
#  info                   :jsonb
#  govuk_guix_revision_id :string
#  backend_type           :string
#  backend_id             :integer
#  backend_data           :jsonb
#

class MiniEnvironment < ApplicationRecord
  has_many :finished_terraform_jobs, dependent: :destroy
  has_many :terraform_states, dependent: :destroy

  belongs_to :govuk_guix_revision, class_name: 'GovukGuix::Revision'
  belongs_to :backend, polymorphic: true

  def enqueued_terraform_jobs
    Que.execute("SELECT * FROM que_jobs WHERE args->>0 = '#{id}'")
  end
end