diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb')
-rw-r--r-- | db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb b/db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb new file mode 100644 index 00000000000..03991cea41c --- /dev/null +++ b/db/migrate/20210622135221_add_foreign_key_for_environment_id_to_environments.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class AddForeignKeyForEnvironmentIdToEnvironments < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + disable_ddl_transaction! + + def up + # `validate: false` option is passed here, because validating the existing rows fails by the orphaned deployments, + # which will be cleaned up in https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64588. + # The validation runs for only new records or updates, so that we can at least + # stop creating orphaned rows. + add_concurrent_foreign_key :deployments, :environments, column: :environment_id, on_delete: :cascade, validate: false + end + + def down + with_lock_retries do + remove_foreign_key_if_exists :deployments, :environments + end + end +end |