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
2719b2f0
Commit
2719b2f0
authored
Jul 07, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify stage_id migration as we now use relations
parent
320229e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
9 deletions
+4
-9
lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
.../background_migration/migrate_build_stage_id_reference.rb
+4
-9
No files found.
lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
View file @
2719b2f0
...
...
@@ -2,19 +2,14 @@ module Gitlab
module
BackgroundMigration
class
MigrateBuildStageIdReference
def
perform
(
start_id
,
stop_id
)
scope
=
if
stop_id
.
to_i
.
nonzero?
"ci_builds.id BETWEEN
#{
start_id
.
to_i
}
AND
#{
stop_id
.
to_i
}
"
else
"ci_builds.id >=
#{
start_id
.
to_i
}
"
end
sql
=
<<-
SQL
.
strip_heredoc
UPDATE
"ci_builds"
SET
"stage_id"
=
UPDATE
ci_builds
SET
stage_id
=
(SELECT id FROM ci_stages
WHERE ci_stages.pipeline_id = ci_builds.commit_id
AND ci_stages.name = ci_builds.stage)
WHERE
#{
scope
}
AND "ci_builds"."stage_id" IS NULL
WHERE ci_builds.id BETWEEN
#{
start_id
.
to_i
}
AND
#{
stop_id
.
to_i
}
AND ci_builds.stage_id IS NULL
SQL
ActiveRecord
::
Base
.
connection
.
execute
(
sql
)
...
...
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