diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-07 15:52:45 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-07-07 15:52:45 +0200 |
commit | 2719b2f0a1ed03170abeca7e78d99a36afb0b65d (patch) | |
tree | bef5e620c69aa6b4b9c963cd59a4f0710536a7bc /lib | |
parent | 320229e12aea3c5f52bcf0fb413bb35138ef7c25 (diff) | |
download | gitlab-ce-2719b2f0a1ed03170abeca7e78d99a36afb0b65d.tar.gz |
Simplify stage_id migration as we now use relations
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/background_migration/migrate_build_stage_id_reference.rb | 13 |
1 files changed, 4 insertions, 9 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 dcd5ecdf322..91540127ea9 100644 --- a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb +++ b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb @@ -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) |