Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9ca20012
Commit
9ca20012
authored
Nov 13, 2019
by
manojmj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add migration for a duplicate foreign key
parent
004e0410
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb
...91107064946_update_oauth_open_id_requests_foreign_keys.rb
+16
-6
No files found.
db/migrate/20191107064946_update_oauth_open_id_requests_foreign_keys.rb
View file @
9ca20012
# frozen_string_literal: true
# rubocop: disable Migration/AddConcurrentForeignKey
class
UpdateOauthOpenIdRequestsForeignKeys
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
remove_foreign_key_if_exists
(
:oauth_openid_requests
,
column: :access_grant_id
)
add_foreign_key
(
:oauth_openid_requests
,
:oauth_access_grants
,
column: :access_grant_id
,
on_delete: :cascad
e
)
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_nam
e
)
end
def
down
remove_foreign_key_if_exists
(
:oauth_openid_requests
,
column: :access_grant_id
)
add_foreign_key
(
:oauth_openid_requests
,
:oauth_access_grants
,
column: :access_grant_id
,
on_delete:
false
,
name:
'fk_oauth_openid_requests_oauth_access_grants_access_grant_id'
)
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment