Database changes to support tf state version replicaiton
What does this MR do?
Database changes to support replicating terraform versioned states. First issue in &4216 (closed)
Fixes #237924 (closed)
Database Info
The terraform_state_versions
table was introduced in !35211 (merged) just today (9/16), so it shouldn't have much in it yet.
Up Migration (Primary Database)
= 20200915152641 AddVerificationStateToTerraformStateVersion: migrating ======
-- change_table(:terraform_state_versions)
-> 0.0055s
== 20200915152641 AddVerificationStateToTerraformStateVersion: migrated (0.0055s)
== 20200915164448 AddVerificationFailureLimitToTerraformStateVersion: migrating
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE terraform_state_versions\nADD CONSTRAINT tf_state_versions_verification_failure_text_limit\nCHECK ( char_length(verification_failure) <= 255 )\nNOT VALID;\n")
-> 0.0010s
-- execute("ALTER TABLE terraform_state_versions VALIDATE CONSTRAINT tf_state_versions_verification_failure_text_limit;")
-> 0.0007s
== 20200915164448 AddVerificationFailureLimitToTerraformStateVersion: migrated (0.0103s)
== 20200915164844 AddVerificationFailureIndexToTerraformStateVersion: migrating
-- transaction_open?()
-> 0.0000s
-- index_exists?(:terraform_state_versions, :verification_failure, {:where=>"(verification_failure IS NOT NULL)", :name=>"terraform_state_versions_verification_failure_partial", :algorithm=>:concurrently})
-> 0.0021s
-- add_index(:terraform_state_versions, :verification_failure, {:where=>"(verification_failure IS NOT NULL)", :name=>"terraform_state_versions_verification_failure_partial", :algorithm=>:concurrently})
-> 0.0024s
-- transaction_open?()
-> 0.0000s
-- index_exists?(:terraform_state_versions, :verification_checksum, {:where=>"(verification_checksum IS NOT NULL)", :name=>"terraform_state_versions_verification_checksum_partial", :algorithm=>:concurrently})
-> 0.0013s
-- add_index(:terraform_state_versions, :verification_checksum, {:where=>"(verification_checksum IS NOT NULL)", :name=>"terraform_state_versions_verification_checksum_partial", :algorithm=>:concurrently})
-> 0.0022s
== 20200915164844 AddVerificationFailureIndexToTerraformStateVersion: migrated (0.0091s)
Down Migrations (Primary Database)
== 20200915164844 AddVerificationFailureIndexToTerraformStateVersion: reverting
-- transaction_open?()
-> 0.0000s
-- indexes(:terraform_state_versions)
-> 0.0033s
-- remove_index(:terraform_state_versions, {:algorithm=>:concurrently, :name=>"terraform_state_versions_verification_failure_partial"})
-> 0.0029s
-- transaction_open?()
-> 0.0000s
-- indexes(:terraform_state_versions)
-> 0.0018s
-- remove_index(:terraform_state_versions, {:algorithm=>:concurrently, :name=>"terraform_state_versions_verification_checksum_partial"})
-> 0.0012s
== 20200915164844 AddVerificationFailureIndexToTerraformStateVersion: reverted (0.0104s)
== 20200915164448 AddVerificationFailureLimitToTerraformStateVersion: reverting
-- execute("ALTER TABLE terraform_state_versions\nDROP CONSTRAINT IF EXISTS tf_state_versions_verification_failure_text_limit\n")
-> 0.0008s
== 20200915164448 AddVerificationFailureLimitToTerraformStateVersion: reverted (0.0038s)
== 20200915152641 AddVerificationStateToTerraformStateVersion: reverting ======
-- remove_column(:terraform_state_versions, :verification_failure, :text, {})
-> 0.0016s
-- remove_column(:terraform_state_versions, :verification_checksum, :binary, {:using=>"verification_checksum::bytea"})
-> 0.0002s
-- remove_column(:terraform_state_versions, :verified_at, :datetime_with_timezone, {})
-> 0.0002s
-- remove_column(:terraform_state_versions, :verification_retry_at, :datetime_with_timezone, {})
-> 0.0002s
-- remove_column(:terraform_state_versions, :verification_retry_count, :integer, {:limit=>2})
-> 0.0002s
== 20200915152641 AddVerificationStateToTerraformStateVersion: reverted (0.0071s)
Up Migration (Geo Tracking Database)
== 20200915152620 CreateTerraformStateVersionRegistry: migrating ==============
-- table_exists?(:terraform_state_version_registry)
-> 0.0003s
-- create_table(:terraform_state_version_registry, {:id=>:bigserial, :force=>:cascade})
-> 0.0100s
-- transaction_open?()
-> 0.0000s
-- execute("ALTER TABLE terraform_state_version_registry\nADD CONSTRAINT check_7827f2d2cf\nCHECK ( char_length(last_sync_failure) <= 255 )\nNOT VALID;\n")
-> 0.0006s
-- execute("ALTER TABLE terraform_state_version_registry VALIDATE CONSTRAINT check_7827f2d2cf;")
-> 0.0006s
== 20200915152620 CreateTerraformStateVersionRegistry: migrated (0.0167s) =====
Down Migration (Geo Tracking Database)
== 20200915152620 CreateTerraformStateVersionRegistry: reverting ==============
-- drop_table(:terraform_state_version_registry)
-> 0.0035s
== 20200915152620 CreateTerraformStateVersionRegistry: reverted (0.0036s) =====
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Alex Ives