Commit 637c65be authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'sh-update-foreign-key-personal-access-tokens' into 'master'

Update foreign key constraint for personal access tokens

Closes #191262

See merge request gitlab-org/gitlab!22305
parents a0838d9a ae79d6d9
---
title: Update foreign key constraint for personal access tokens
merge_request: 22305
author:
type: fixed
# frozen_string_literal: true
class UpdatePersonalAccessTokensUserIdForeignKey < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
CONSTRAINT_NAME = 'fk_personal_access_tokens_user_id'
disable_ddl_transaction!
def up
add_concurrent_foreign_key(:personal_access_tokens, :users, column: :user_id, on_delete: :cascade, name: CONSTRAINT_NAME)
remove_foreign_key_if_exists(:personal_access_tokens, column: :user_id, on_delete: nil)
end
def down
add_concurrent_foreign_key(:personal_access_tokens, :users, column: :user_id, on_delete: nil)
remove_foreign_key_if_exists(:personal_access_tokens, column: :user_id, on_delete: :cascade, name: CONSTRAINT_NAME)
end
end
...@@ -4687,7 +4687,7 @@ ActiveRecord::Schema.define(version: 2019_12_29_140154) do ...@@ -4687,7 +4687,7 @@ ActiveRecord::Schema.define(version: 2019_12_29_140154) do
add_foreign_key "pages_domains", "projects", name: "fk_ea2f6dfc6f", on_delete: :cascade add_foreign_key "pages_domains", "projects", name: "fk_ea2f6dfc6f", on_delete: :cascade
add_foreign_key "path_locks", "projects", name: "fk_5265c98f24", on_delete: :cascade add_foreign_key "path_locks", "projects", name: "fk_5265c98f24", on_delete: :cascade
add_foreign_key "path_locks", "users" add_foreign_key "path_locks", "users"
add_foreign_key "personal_access_tokens", "users" add_foreign_key "personal_access_tokens", "users", name: "fk_personal_access_tokens_user_id", on_delete: :cascade
add_foreign_key "plan_limits", "plans", on_delete: :cascade add_foreign_key "plan_limits", "plans", on_delete: :cascade
add_foreign_key "pool_repositories", "projects", column: "source_project_id", on_delete: :nullify add_foreign_key "pool_repositories", "projects", column: "source_project_id", on_delete: :nullify
add_foreign_key "pool_repositories", "shards", on_delete: :restrict add_foreign_key "pool_repositories", "shards", on_delete: :restrict
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment