aboutsummaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-04-07 15:22:36 +0100
committerChristopher Baines <mail@cbaines.net>2018-04-12 08:30:56 +0100
commit13bf88b2e8e6cec0d2207fe7b92f7446eea49354 (patch)
treec408c6bfd9e50cdead72f8cbb5a45a7fe48bd0d9 /app/models
parent6b7f16aa3073a4d5cf5d3312a005ac4d2463ef71 (diff)
downloadgovuk-mini-environment-admin-13bf88b2e8e6cec0d2207fe7b92f7446eea49354.tar
govuk-mini-environment-admin-13bf88b2e8e6cec0d2207fe7b92f7446eea49354.tar.gz
Change mini_environment_id to model_id on FinishedTerraformJob
In preparation of setting up backends through Terraform as well.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/finished_terraform_job.rb10
-rw-r--r--app/models/mini_environment.rb10
2 files changed, 14 insertions, 6 deletions
diff --git a/app/models/finished_terraform_job.rb b/app/models/finished_terraform_job.rb
index 6397b27..ca2cb94 100644
--- a/app/models/finished_terraform_job.rb
+++ b/app/models/finished_terraform_job.rb
@@ -22,11 +22,11 @@
#
# Table name: finished_terraform_jobs
#
-# id :integer not null, primary key
-# mini_environment_id :integer
-# job_class :string
-# created_at :datetime not null
-# updated_at :datetime not null
+# id :integer not null, primary key
+# model_id :integer
+# job_class :string
+# created_at :datetime not null
+# updated_at :datetime not null
#
class FinishedTerraformJob < ApplicationRecord
diff --git a/app/models/mini_environment.rb b/app/models/mini_environment.rb
index f2a03ff..712e3a0 100644
--- a/app/models/mini_environment.rb
+++ b/app/models/mini_environment.rb
@@ -35,7 +35,15 @@
#
class MiniEnvironment < ApplicationRecord
- has_many :finished_terraform_jobs, dependent: :destroy
+ has_many(
+ :finished_terraform_jobs,
+ lambda do |mini_environment|
+ unscope(:where).where(
+ 'finished_terraform_jobs.model_id = ?', mini_environment.id
+ )
+ end,
+ dependent: :destroy
+ )
has_many :terraform_states, dependent: :destroy
belongs_to :govuk_guix_revision, class_name: 'GovukGuix::Revision'