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
iv
gitlab-ce
Commits
a37e591e
Commit
a37e591e
authored
Sep 21, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use INSERT INTO to insert tags
parent
b2a90216
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
lib/ci/migrate/tags.rb
lib/ci/migrate/tags.rb
+8
-7
No files found.
lib/ci/migrate/tags.rb
View file @
a37e591e
...
...
@@ -4,14 +4,15 @@ module Ci
module
Migrate
class
Tags
def
restore
ActiveRecord
::
Base
.
transaction
do
puts
'Inserting tags...'
connection
.
execute
(
'INSERT INTO tags (name) '
+
'SELECT ci_tags.name FROM ci_tags '
+
'WHERE (SELECT COUNT(*) FROM tags WHERE tags.name = ci_tags.name)=0'
)
puts
'Inserting tags...'
connection
.
select_all
(
'SELECT ci_tags.name FROM ci_tags'
).
each
do
|
tag
|
begin
connection
.
execute
(
"INSERT INTO tags (name) VALUES(
#{
ActiveRecord
::
Base
::
sanitize
(
tag
[
'name'
])
}
)"
)
rescue
ActiveRecord
::
RecordNotUnique
end
end
ActiveRecord
::
Base
.
transaction
do
puts
'Deleting old taggings...'
connection
.
execute
"DELETE FROM taggings WHERE context = 'tags' AND taggable_type LIKE 'Ci::%'"
...
...
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