diff options
Diffstat (limited to 'db/post_migrate/20210920232025_remove_ci_builds_foreign_key_from_terraform_state_versions.rb')
-rw-r--r-- | db/post_migrate/20210920232025_remove_ci_builds_foreign_key_from_terraform_state_versions.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/post_migrate/20210920232025_remove_ci_builds_foreign_key_from_terraform_state_versions.rb b/db/post_migrate/20210920232025_remove_ci_builds_foreign_key_from_terraform_state_versions.rb new file mode 100644 index 00000000000..7435a2c889b --- /dev/null +++ b/db/post_migrate/20210920232025_remove_ci_builds_foreign_key_from_terraform_state_versions.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class RemoveCiBuildsForeignKeyFromTerraformStateVersions < Gitlab::Database::Migration[1.0] + disable_ddl_transaction! + + def up + with_lock_retries do + remove_foreign_key_if_exists(:terraform_state_versions, :ci_builds) + end + end + + def down + add_concurrent_foreign_key(:terraform_state_versions, :ci_builds, column: :ci_build_id, on_delete: :nullify) + end +end |