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
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-21 12:02:18 +0300
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-06-21 14:18:38 +0300
commit885d63d9ed5802803fa4797e63f4f7e02c5a73ab (patch)
tree67f5780dc9d826246969495056718f497b0a1705 /db/post_migrate
parent6b9608e13e20fe579b861b911880603a372f2f27 (diff)
Fix adding/removing foreign keys on MySQL
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb1
-rw-r--r--db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb2
2 files changed, 3 insertions, 0 deletions
diff --git a/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb
index a2c0b0c651b..3879cf9133b 100644
--- a/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb
+++ b/db/post_migrate/20170526185901_remove_stage_id_index_from_builds.rb
@@ -7,6 +7,7 @@ class RemoveStageIdIndexFromBuilds < ActiveRecord::Migration
def up
if index_exists?(:ci_builds, :stage_id)
+ remove_foreign_key(:ci_builds, column: :stage_id)
remove_concurrent_index(:ci_builds, :stage_id)
end
end
diff --git a/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
index acbe16812d2..7d6609b18bf 100644
--- a/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
+++ b/db/post_migrate/20170621102400_add_stage_id_index_to_builds.rb
@@ -7,12 +7,14 @@ class AddStageIdIndexToBuilds < ActiveRecord::Migration
def up
unless index_exists?(:ci_builds, :stage_id)
+ add_concurrent_foreign_key(:ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade)
add_concurrent_index(:ci_builds, :stage_id)
end
end
def down
if index_exists?(:ci_builds, :stage_id)
+ remove_foreign_key(:ci_builds, column: :stage_id)
remove_concurrent_index(:ci_builds, :stage_id)
end
end