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
757084f7
Commit
757084f7
authored
May 08, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
parents
5b8712e4
cd2659fd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
db/migrate/20150425164646_gitlab_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
...nge_collation_for_tag_names.acts_as_taggable_on_engine.rb
+10
-0
db/migrate/20150425164647_remove_duplicate_tags.rb
db/migrate/20150425164647_remove_duplicate_tags.rb
+16
-0
db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb
..._add_missing_unique_indices.acts_as_taggable_on_engine.rb
+9
-2
No files found.
db/migrate/20150425164646_gitlab_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
0 → 100644
View file @
757084f7
# This migration is a duplicate of 20150425164651_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
# It shold be applied before the index additions to ensure that `name` is case sensitive.
class
GitlabChangeCollationForTagNames
<
ActiveRecord
::
Migration
def
up
if
ActsAsTaggableOn
::
Utils
.
using_mysql?
execute
(
"ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;"
)
end
end
end
db/migrate/20150425164647_remove_duplicate_tags.rb
0 → 100644
View file @
757084f7
class
RemoveDuplicateTags
<
ActiveRecord
::
Migration
def
up
select_all
(
"SELECT name, COUNT(id) as cnt FROM tags GROUP BY name HAVING COUNT(id) > 1"
).
each
do
|
tag
|
duplicate_ids
=
select_all
(
"SELECT id FROM tags WHERE name = '
#{
tag
[
"name"
]
}
'"
).
map
{
|
tag
|
tag
[
"id"
]}
origin_tag_id
=
duplicate_ids
.
first
duplicate_ids
.
delete
origin_tag_id
execute
(
"UPDATE taggings SET tag_id =
#{
origin_tag_id
}
WHERE tag_id IN(
#{
duplicate_ids
.
join
(
","
)
}
)"
)
execute
(
"DELETE FROM tags WHERE id IN(
#{
duplicate_ids
.
join
(
","
)
}
)"
)
end
end
def
down
end
end
db/migrate/20150425164648_add_missing_unique_indices.acts_as_taggable_on_engine.rb
View file @
757084f7
...
...
@@ -3,8 +3,15 @@ class AddMissingUniqueIndices < ActiveRecord::Migration
def
self
.
up
add_index
:tags
,
:name
,
unique:
true
# pre-GitLab v6.7.0 may not have these indices since there were no
# migrations for them
if
index_exists?
(
:taggings
,
:tag_id
)
remove_index
:taggings
,
:tag_id
end
if
index_exists?
(
:taggings
,
[
:taggable_id
,
:taggable_type
,
:context
])
remove_index
:taggings
,
[
:taggable_id
,
:taggable_type
,
:context
]
end
add_index
:taggings
,
[
:tag_id
,
:taggable_id
,
:taggable_type
,
:context
,
:tagger_id
,
:tagger_type
],
unique:
true
,
name:
'taggings_idx'
...
...
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