aboutsummaryrefslogtreecommitdiff
path: root/app/models/mini_environment.rb
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/mini_environment.rb
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/mini_environment.rb')
-rw-r--r--app/models/mini_environment.rb10
1 files changed, 9 insertions, 1 deletions
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'