Migrate pipeline stages only when not migrated already

This commit is contained in:
Grzegorz Bizon 2017-06-05 13:21:49 +02:00
parent 5b718d4825
commit af72fa9c9c
1 changed files with 3 additions and 3 deletions

View File

@ -11,9 +11,9 @@ class MigratePipelineStages < ActiveRecord::Migration
execute <<-SQL.strip_heredoc
INSERT INTO ci_stages (project_id, pipeline_id, name)
SELECT project_id, commit_id, stage FROM ci_builds
WHERE stage IS NOT NULL
GROUP BY project_id, commit_id, stage, stage_idx
ORDER BY stage_idx
WHERE stage IS NOT NULL AND stage_id IS NULL
GROUP BY project_id, commit_id, stage
ORDER BY MAX(stage_idx)
SQL
end