aboutsummaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-04-07 15:27:38 +0100
committerChristopher Baines <mail@cbaines.net>2018-04-12 08:30:56 +0100
commit2e97d9f957eff4ba66f1c4c65ff0b5156471cf6c (patch)
tree7b55cfce7488fc59d75374e49850829f0931fb76 /db
parent13bf88b2e8e6cec0d2207fe7b92f7446eea49354 (diff)
downloadgovuk-mini-environment-admin-2e97d9f957eff4ba66f1c4c65ff0b5156471cf6c.tar
govuk-mini-environment-admin-2e97d9f957eff4ba66f1c4c65ff0b5156471cf6c.tar.gz
Change mini_environment_id to state_id on TerraformState
To allow supporting tracking related TerraformStates for backends as well.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20180406123612_add_state_id_to_terraform_state.rb10
-rw-r--r--db/migrate/20180406124443_remove_mini_environment_id_from_terraform_state.rb5
2 files changed, 15 insertions, 0 deletions
diff --git a/db/migrate/20180406123612_add_state_id_to_terraform_state.rb b/db/migrate/20180406123612_add_state_id_to_terraform_state.rb
new file mode 100644
index 0000000..4d2e668
--- /dev/null
+++ b/db/migrate/20180406123612_add_state_id_to_terraform_state.rb
@@ -0,0 +1,10 @@
+class AddStateIdToTerraformState < ActiveRecord::Migration[5.1]
+ def change
+ add_column :terraform_states, :state_id, :string, null: false, default: ''
+ execute(
+ "UPDATE terraform_states "\
+ "SET state_id = 'mini_environment/' || mini_environment_id::text"
+ )
+ change_column :terraform_states, :state_id, :string, null: false
+ end
+end
diff --git a/db/migrate/20180406124443_remove_mini_environment_id_from_terraform_state.rb b/db/migrate/20180406124443_remove_mini_environment_id_from_terraform_state.rb
new file mode 100644
index 0000000..129a264
--- /dev/null
+++ b/db/migrate/20180406124443_remove_mini_environment_id_from_terraform_state.rb
@@ -0,0 +1,5 @@
+class RemoveMiniEnvironmentIdFromTerraformState < ActiveRecord::Migration[5.1]
+ def change
+ remove_column :terraform_states, :mini_environment_id
+ end
+end