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
6db8253c
Commit
6db8253c
authored
Jun 29, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve readability of build stage id migration query
parent
c7f6e5ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
.../background_migration/migrate_build_stage_id_reference.rb
+7
-6
spec/migrations/migrate_stage_id_reference_in_background_spec.rb
...grations/migrate_stage_id_reference_in_background_spec.rb
+2
-2
No files found.
lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
View file @
6db8253c
...
...
@@ -5,12 +5,13 @@ module Gitlab
raise
ArgumentError
unless
id
.
present?
sql
=
<<-
SQL
.
strip_heredoc
UPDATE "ci_builds" SET "stage_id" = (
SELECT id FROM ci_stages
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 "ci_builds"."id" =
#{
id
}
AND "ci_builds"."stage_id" IS NULL
AND ci_stages.name = ci_builds.stage)
WHERE "ci_builds"."id" =
#{
id
}
AND "ci_builds"."stage_id" IS NULL
SQL
ActiveRecord
::
Base
.
connection
.
execute
(
sql
)
...
...
spec/migrations/migrate_stage_id_reference_in_background_spec.rb
View file @
6db8253c
...
...
@@ -58,11 +58,11 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
it
'schedules background migrations'
do
Sidekiq
::
Testing
.
inline!
do
expect
(
jobs
.
where
(
stage_id:
nil
)
).
to
be_present
expect
(
jobs
.
where
(
stage_id:
nil
)
.
count
).
to
eq
5
migrate!
expect
(
jobs
.
where
(
stage_id:
nil
)
).
to
be_one
expect
(
jobs
.
where
(
stage_id:
nil
)
.
count
).
to
eq
1
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