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-07-07 10:35:28 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-07-07 16:08:15 +0300
commitfb89ba24825853ca29b804a4a08f7c83210f09db (patch)
tree5906aab32eb7210888762e27cc60c029503e7a73 /lib
parent2917f4868a19ab17a0217703c7b842261f8b9e46 (diff)
Schedule stage_id background migration in ranges
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/background_migration/migrate_build_stage_id_reference.rb11
-rw-r--r--lib/gitlab/database/migration_helpers.rb2
2 files changed, 9 insertions, 4 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 d1d0a968588..0705b26056d 100644
--- a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
+++ b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
@@ -1,15 +1,20 @@
module Gitlab
module BackgroundMigration
class MigrateBuildStageIdReference
- def perform(id)
+ def perform(start_id, stop_id)
+ scope = if stop_id.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" =
(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.to_i}
- AND "ci_builds"."stage_id" IS NULL
+ WHERE #{scope} AND "ci_builds"."stage_id" IS NULL
SQL
ActiveRecord::Base.connection.execute(sql)
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index 5acc96331c0..b6883704da0 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -296,7 +296,7 @@ module Gitlab
MSG
end
- # raise 'This method requires a block!' unless block_given?
+ raise ArgumentError, 'This method requires a block!' unless block_given?
table_arel = Arel::Table.new(table)