Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-29 16:26:47 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-07 16:08:15 +0300
commitd953f1762ea9d4be0e53d5280b9f38224b39e67b (patch)
treed9e11ef04297f93b71b08d4e624d2cf9b1f24b9f /lib
parent01128b130b32fac3481fb3b386b649cb047b4b1f (diff)
Improve readability of build stage id migration query
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/migrate_build_stage_id_reference.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
index 711126ea0d3..c8669ca3272 100644
--- a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
+++ b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
@@ -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
- 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
+ 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
SQL
ActiveRecord::Base.connection.execute(sql)