summaryrefslogtreecommitdiff
path: root/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-24 15:21:20 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-01-25 12:08:57 +0100
commitce71b1ce072b024802e7e4ff07486e253c24d964 (patch)
tree34f0c2014b5ec170df10b65a34ebfc664d17eb12 /db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
parente4aac7f365105cbc7547239066db075a44d69788 (diff)
downloadgitlab-ce-ce71b1ce072b024802e7e4ff07486e253c24d964.tar.gz
Fix removing redundant pipeline stages on MySQL
Diffstat (limited to 'db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb')
-rw-r--r--db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
index c1705cd8757..597f6c3ee48 100644
--- a/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
+++ b/db/post_migrate/20180119121225_remove_redundant_pipeline_stages.rb
@@ -12,12 +12,19 @@ class RemoveRedundantPipelineStages < ActiveRecord::Migration
SQL
execute <<~SQL
- UPDATE ci_builds SET stage_id = NULL WHERE ci_builds.stage_id IN (#{redundant_stages_ids})
+ UPDATE ci_builds SET stage_id = NULL WHERE stage_id IN (#{redundant_stages_ids})
SQL
- execute <<~SQL
- DELETE FROM ci_stages WHERE ci_stages.id IN (#{redundant_stages_ids})
- SQL
+ if Gitlab::Database.postgresql?
+ execute <<~SQL
+ DELETE FROM ci_stages WHERE id IN (#{redundant_stages_ids})
+ SQL
+ else # We can't modify a table we are selecting from on MySQL
+ execute <<~SQL
+ DELETE a FROM ci_stages AS a, ci_stages AS b
+ WHERE a.pipeline_id = b.pipeline_id AND a.name = b.name
+ SQL
+ end
end
def down