diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-21 12:02:18 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-06-21 14:18:38 +0300 |
commit | 885d63d9ed5802803fa4797e63f4f7e02c5a73ab (patch) | |
tree | 67f5780dc9d826246969495056718f497b0a1705 /db | |
parent | 6b9608e13e20fe579b861b911880603a372f2f27 (diff) |
Fix adding/removing foreign keys on MySQL
Diffstat (limited to 'db')
3 files changed, 3 insertions, 4 deletions
diff --git a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb index 2eeb2c481eb..d27cba76d81 100644 --- a/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb +++ b/db/migrate/20170526185602_add_stage_id_to_ci_builds.rb @@ -3,15 +3,11 @@ class AddStageIdToCiBuilds < ActiveRecord::Migration DOWNTIME = false - disable_ddl_transaction! - def up add_column :ci_builds, :stage_id, :integer - add_concurrent_foreign_key :ci_builds, :ci_stages, column: :stage_id, on_delete: :cascade end def down - remove_foreign_key :ci_builds, column: :stage_id remove_column :ci_builds, :stage_id, :integer end end 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 |