Commit 5a31bbe8 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make pipeline stages ref migration more readable

parent cafb1bfe
...@@ -6,9 +6,11 @@ class MigrateBuildStageReference < ActiveRecord::Migration ...@@ -6,9 +6,11 @@ class MigrateBuildStageReference < ActiveRecord::Migration
def up def up
disable_statement_timeout disable_statement_timeout
stage_id = Arel.sql('(SELECT id FROM ci_stages ' \ stage_id = Arel.sql(<<-SQL.strip_heredoc
'WHERE ci_stages.pipeline_id = ci_builds.commit_id ' \ (SELECT id FROM ci_stages
'AND ci_stages.name = ci_builds.stage)') WHERE ci_stages.pipeline_id = ci_builds.commit_id
AND ci_stages.name = ci_builds.stage)
SQL
update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query| update_column_in_batches(:ci_builds, :stage_id, stage_id) do |table, query|
query.where(table[:stage_id].eq(nil)) query.where(table[:stage_id].eq(nil))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment