diff options
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 |