BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1f84518a
Commit
1f84518a
authored
Apr 25, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'index_on_iid' into 'master'
Add uniq db index on project_id+iid Because: * its faster * it solves problem with repeating iid's in one project
parents
d89f26e0
ae7bd9f7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
0 deletions
+37
-0
CHANGELOG
CHANGELOG
+1
-0
milestone.rb
app/models/milestone.rb
+1
-0
20140416074002_add_index_on_iid.rb
db/migrate/20140416074002_add_index_on_iid.rb
+32
-0
schema.rb
db/schema.rb
+3
-0
No files found.
CHANGELOG
View file @
1f84518a
v 6.9.0
- Store Rails cache data in the Redis `cache:gitlab` namespace
- Adjust MySQL limits for existing installations
- Add db index on project_id+iid column. This prevents duplicate on iid.
v 6.8.0
- Ability to at mention users that are participating in issue and merge req. discussion
...
...
app/models/milestone.rb
View file @
1f84518a
...
...
@@ -25,6 +25,7 @@ class Milestone < ActiveRecord::Base
scope
:active
,
->
{
with_state
(
:active
)
}
scope
:closed
,
->
{
with_state
(
:closed
)
}
scope
:of_projects
,
->
(
ids
)
{
where
(
project_id:
ids
)
}
validates
:title
,
presence:
true
validates
:project
,
presence:
true
...
...
db/migrate/20140416074002_add_index_on_iid.rb
0 → 100644
View file @
1f84518a
class
AddIndexOnIid
<
ActiveRecord
::
Migration
def
change
RemoveDuplicateIid
.
clean
(
Issue
)
RemoveDuplicateIid
.
clean
(
MergeRequest
,
'target_project_id'
)
RemoveDuplicateIid
.
clean
(
Milestone
)
add_index
:issues
,
[
:project_id
,
:iid
],
unique:
true
add_index
:merge_requests
,
[
:target_project_id
,
:iid
],
unique:
true
add_index
:milestones
,
[
:project_id
,
:iid
],
unique:
true
end
end
class
RemoveDuplicateIid
def
self
.
clean
(
klass
,
project_field
=
'project_id'
)
duplicates
=
klass
.
find_by_sql
(
"SELECT iid,
#{
project_field
}
FROM
#{
klass
.
table_name
}
GROUP BY
#{
project_field
}
, iid HAVING COUNT(*) > 1"
)
duplicates
.
each
do
|
duplicate
|
project_id
=
duplicate
.
send
(
project_field
)
iid
=
duplicate
.
iid
items
=
klass
.
of_projects
(
project_id
).
where
(
iid:
iid
)
if
items
.
size
>
1
puts
"Remove
#{
klass
.
name
}
duplicates for iid:
#{
iid
}
and project_id:
#{
project_id
}
"
items
.
shift
items
.
each
do
|
item
|
item
.
destroy
puts
'.'
end
end
end
end
end
db/schema.rb
View file @
1f84518a
...
...
@@ -93,6 +93,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do
add_index
"issues"
,
[
"author_id"
],
name:
"index_issues_on_author_id"
,
using: :btree
add_index
"issues"
,
[
"created_at"
],
name:
"index_issues_on_created_at"
,
using: :btree
add_index
"issues"
,
[
"milestone_id"
],
name:
"index_issues_on_milestone_id"
,
using: :btree
add_index
"issues"
,
[
"project_id"
,
"iid"
],
name:
"index_issues_on_project_id_and_iid"
,
unique:
true
,
using: :btree
add_index
"issues"
,
[
"project_id"
],
name:
"index_issues_on_project_id"
,
using: :btree
add_index
"issues"
,
[
"title"
],
name:
"index_issues_on_title"
,
using: :btree
...
...
@@ -143,6 +144,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do
add_index
"merge_requests"
,
[
"source_branch"
],
name:
"index_merge_requests_on_source_branch"
,
using: :btree
add_index
"merge_requests"
,
[
"source_project_id"
],
name:
"index_merge_requests_on_source_project_id"
,
using: :btree
add_index
"merge_requests"
,
[
"target_branch"
],
name:
"index_merge_requests_on_target_branch"
,
using: :btree
add_index
"merge_requests"
,
[
"target_project_id"
,
"iid"
],
name:
"index_merge_requests_on_target_project_id_and_iid"
,
unique:
true
,
using: :btree
add_index
"merge_requests"
,
[
"title"
],
name:
"index_merge_requests_on_title"
,
using: :btree
create_table
"milestones"
,
force:
true
do
|
t
|
...
...
@@ -157,6 +159,7 @@ ActiveRecord::Schema.define(version: 20140416185734) do
end
add_index
"milestones"
,
[
"due_date"
],
name:
"index_milestones_on_due_date"
,
using: :btree
add_index
"milestones"
,
[
"project_id"
,
"iid"
],
name:
"index_milestones_on_project_id_and_iid"
,
unique:
true
,
using: :btree
add_index
"milestones"
,
[
"project_id"
],
name:
"index_milestones_on_project_id"
,
using: :btree
create_table
"namespaces"
,
force:
true
do
|
t
|
...
...
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