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
9a3d0f1d
Commit
9a3d0f1d
authored
Sep 15, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add rake task to migrate CI tags
parent
ebd06d7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
1 deletion
+84
-1
db/migrate/20150914215247_add_ci_tags.rb
db/migrate/20150914215247_add_ci_tags.rb
+23
-0
db/schema.rb
db/schema.rb
+21
-1
lib/tasks/ci/migrate.rake
lib/tasks/ci/migrate.rake
+40
-0
No files found.
db/migrate/20150914215247_add_ci_tags.rb
0 → 100644
View file @
9a3d0f1d
class
AddCiTags
<
ActiveRecord
::
Migration
def
change
create_table
"ci_taggings"
,
force:
true
do
|
t
|
t
.
integer
"tag_id"
t
.
integer
"taggable_id"
t
.
string
"taggable_type"
t
.
integer
"tagger_id"
t
.
string
"tagger_type"
t
.
string
"context"
,
limit:
128
t
.
datetime
"created_at"
end
add_index
"ci_taggings"
,
[
"tag_id"
,
"taggable_id"
,
"taggable_type"
,
"context"
,
"tagger_id"
,
"tagger_type"
],
name:
"ci_taggings_idx"
,
unique:
true
,
using: :btree
add_index
"ci_taggings"
,
[
"taggable_id"
,
"taggable_type"
,
"context"
],
name:
"index_ci_taggings_on_taggable_id_and_taggable_type_and_context"
,
using: :btree
create_table
"ci_tags"
,
force:
true
do
|
t
|
t
.
string
"name"
t
.
integer
"taggings_count"
,
default:
0
end
add_index
"ci_tags"
,
[
"name"
],
name:
"index_ci_tags_on_name"
,
unique:
true
,
using: :btree
end
end
db/schema.rb
View file @
9a3d0f1d
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201509
02001023
)
do
ActiveRecord
::
Schema
.
define
(
version:
201509
14215247
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -223,6 +223,26 @@ ActiveRecord::Schema.define(version: 20150902001023) do
add_index
"ci_sessions"
,
[
"session_id"
],
name:
"index_ci_sessions_on_session_id"
,
using: :btree
add_index
"ci_sessions"
,
[
"updated_at"
],
name:
"index_ci_sessions_on_updated_at"
,
using: :btree
create_table
"ci_taggings"
,
force:
true
do
|
t
|
t
.
integer
"tag_id"
t
.
integer
"taggable_id"
t
.
string
"taggable_type"
t
.
integer
"tagger_id"
t
.
string
"tagger_type"
t
.
string
"context"
,
limit:
128
t
.
datetime
"created_at"
end
add_index
"ci_taggings"
,
[
"tag_id"
,
"taggable_id"
,
"taggable_type"
,
"context"
,
"tagger_id"
,
"tagger_type"
],
name:
"ci_taggings_idx"
,
unique:
true
,
using: :btree
add_index
"ci_taggings"
,
[
"taggable_id"
,
"taggable_type"
,
"context"
],
name:
"index_ci_taggings_on_taggable_id_and_taggable_type_and_context"
,
using: :btree
create_table
"ci_tags"
,
force:
true
do
|
t
|
t
.
string
"name"
t
.
integer
"taggings_count"
,
default:
0
end
add_index
"ci_tags"
,
[
"name"
],
name:
"index_ci_tags_on_name"
,
unique:
true
,
using: :btree
create_table
"ci_trigger_requests"
,
force:
true
do
|
t
|
t
.
integer
"trigger_id"
,
null:
false
t
.
text
"variables"
...
...
lib/tasks/ci/migrate.rake
0 → 100644
View file @
9a3d0f1d
namespace
:ci
do
namespace
:migrate
do
def
list_objects
(
type
)
ids
=
ActiveRecord
::
Base
.
connection
.
select_all
(
'select distinct taggable_id from ci_taggings where taggable_type = $1'
,
nil
,
[[
nil
,
type
]]
)
ids
.
map
{
|
id
|
id
[
'taggable_id'
]
}
end
def
list_tags
(
type
,
id
)
tags
=
ActiveRecord
::
Base
.
connection
.
select_all
(
'select ci_tags.name from ci_tags '
+
'join ci_taggings on ci_tags.id = ci_taggings.tag_id '
+
'where taggable_type = $1 and taggable_id = $2 and context = $3'
,
nil
,
[[
nil
,
type
],
[
nil
,
id
],
[
nil
,
'tags'
]]
)
tags
.
map
{
|
tag
|
tag
[
'name'
]
}
end
desc
'GITLAB | Migrate CI tags'
task
tags: :environment
do
list_objects
(
'Runner'
).
each
do
|
id
|
runner
=
Ci
::
Runner
.
find_by_id
(
id
)
if
runner
tags
=
list_tags
(
'Runner'
,
id
)
runner
.
update_attributes
(
tag_list:
tags
)
end
end
list_objects
(
'Build'
).
each
do
|
id
|
build
=
Ci
::
Build
.
find_by_id
(
id
)
if
build
tags
=
list_tags
(
'Build'
,
id
)
build
.
update_attributes
(
tag_list:
tags
)
end
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