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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
c0bfe9db
Commit
c0bfe9db
authored
Mar 20, 2018
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch MySQL's odd foreign key behavior.
parent
58a99463
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb
...e/20180320182229_add_indexes_for_user_activity_queries.rb
+14
-1
No files found.
db/migrate/20180320182229_add_indexes_for_user_activity_queries.rb
View file @
c0bfe9db
...
...
@@ -12,6 +12,19 @@ class AddIndexesForUserActivityQueries < ActiveRecord::Migration
def
down
remove_concurrent_index
:events
,
[
:project_id
,
:author_id
]
patch_foreign_keys
do
remove_concurrent_index
:user_interacted_projects
,
:user_id
end
end
private
def
patch_foreign_keys
# MySQL doesn't like to remove the index with a foreign key using it.
remove_foreign_key
:user_interacted_projects
,
:users
unless
Gitlab
::
Database
.
postgresql?
yield
# Let's re-add the foreign key using the existing index on (user_id, project_id)
add_concurrent_foreign_key
:user_interacted_projects
,
:users
,
column: :user_id
unless
Gitlab
::
Database
.
postgresql?
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