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
b9bc8d2f
Commit
b9bc8d2f
authored
Jul 14, 2020
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Keyword argument remove_concurrent_index_by_name
In order to meet frequent developer expectations and prevent bugs
parent
798e3475
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+4
-0
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+13
-0
No files found.
lib/gitlab/database/migration_helpers.rb
View file @
b9bc8d2f
...
...
@@ -136,6 +136,10 @@ module Gitlab
'in the body of your migration class'
end
index_name
=
index_name
[
:name
]
if
index_name
.
is_a?
(
Hash
)
raise
'remove_concurrent_index_by_name must get an index name as the second argument'
if
index_name
.
blank?
options
=
options
.
merge
({
algorithm: :concurrently
})
unless
index_exists_by_name?
(
table_name
,
index_name
)
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
b9bc8d2f
...
...
@@ -178,6 +178,19 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
model
.
remove_concurrent_index_by_name
(
:users
,
"index_x_by_y"
)
end
it
'removes the index with keyword arguments'
do
expect
(
model
).
to
receive
(
:remove_index
)
.
with
(
:users
,
{
algorithm: :concurrently
,
name:
"index_x_by_y"
})
model
.
remove_concurrent_index_by_name
(
:users
,
name:
"index_x_by_y"
)
end
it
'raises an error if the index is blank'
do
expect
do
model
.
remove_concurrent_index_by_name
(
:users
,
wrong_key:
"index_x_by_y"
)
end
.
to
raise_error
'remove_concurrent_index_by_name must get an index name as the second argument'
end
end
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