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/db
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-06 15:32:24 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-06 15:32:24 +0300
commitb55aad4cc3bf7723f4531635bbb31ab44cae17a9 (patch)
tree2224c2c5916aadc3e59646de2d864183c97a15eb /db
parent559521ce484d4a95bf3b6ac23bd48c497fdf2703 (diff)
Migrate stages only with correct foreign references
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20170526185842_migrate_pipeline_stages.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/db/post_migrate/20170526185842_migrate_pipeline_stages.rb b/db/post_migrate/20170526185842_migrate_pipeline_stages.rb
index 37ccf9fc105..afd4db183c2 100644
--- a/db/post_migrate/20170526185842_migrate_pipeline_stages.rb
+++ b/db/post_migrate/20170526185842_migrate_pipeline_stages.rb
@@ -11,7 +11,10 @@ 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 AND stage_id IS NULL
+ WHERE stage IS NOT NULL
+ AND stage_id IS NULL
+ AND EXISTS (SELECT 1 FROM projects WHERE projects.id = ci_builds.project_id)
+ AND EXISTS (SELECT 1 FROM ci_pipelines WHERE ci_pipelines.id = ci_builds.commit_id)
GROUP BY project_id, commit_id, stage
ORDER BY MAX(stage_idx)
SQL