diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-03 18:06:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-03 18:06:20 +0300 |
commit | 4204cf308596e0e26f578a6e2da88f49c0f4aad9 (patch) | |
tree | 644447bcb576a459e079318b06712b7c89416e2b /db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb | |
parent | cd4cb29b2c304f00d238ee72fe40c767cb3e2675 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb')
-rw-r--r-- | db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb b/db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb new file mode 100644 index 00000000000..439610758a6 --- /dev/null +++ b/db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +class UpdateOauthOpenIdRequestsForeignKeys < ActiveRecord::Migration[5.2] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + disable_ddl_transaction! + + def up + add_concurrent_foreign_key(:oauth_openid_requests, :oauth_access_grants, column: :access_grant_id, on_delete: :cascade, name: new_foreign_key_name) + remove_foreign_key_if_exists(:oauth_openid_requests, name: existing_foreign_key_name) + end + + def down + add_concurrent_foreign_key(:oauth_openid_requests, :oauth_access_grants, column: :access_grant_id, on_delete: false, name: existing_foreign_key_name) + remove_foreign_key_if_exists(:oauth_openid_requests, name: new_foreign_key_name) + end + + private + + def new_foreign_key_name + concurrent_foreign_key_name(:oauth_openid_requests, :access_grant_id) + end + + def existing_foreign_key_name + 'fk_oauth_openid_requests_oauth_access_grants_access_grant_id' + end +end |