summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-06-01 10:57:42 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2017-06-01 10:57:42 +0000
commit358662a9f7474b41755ec0128efaaa8bef3cb249 (patch)
treed5eeed464c0e4e42a978edceab561b48ba03cd24 /db
parentb410322990f6f5b656aaac00c4a4a3b810944eac (diff)
parentc4067ed6eda1757e3757f22ad8587eeaa04d4be5 (diff)
downloadgitlab-ce-358662a9f7474b41755ec0128efaaa8bef3cb249.tar.gz
Merge branch 'zj-drop-fk-if-exists' into 'master'
Only remove FK if it exists See merge request !11828
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb b/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb
index 6116ca59ee4..1587eee06ae 100644
--- a/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb
+++ b/db/migrate/20170425112628_remove_foreigh_key_ci_trigger_schedules.rb
@@ -4,10 +4,20 @@ class RemoveForeighKeyCiTriggerSchedules < ActiveRecord::Migration
DOWNTIME = false
def up
- remove_foreign_key :ci_trigger_schedules, column: :trigger_id
+ if fk_on_trigger_schedules?
+ remove_foreign_key :ci_trigger_schedules, column: :trigger_id
+ end
end
def down
# no op, the foreign key should not have been here
end
+
+ private
+
+ # Not made more generic and lifted to the helpers as Rails 5 will provide
+ # such an API
+ def fk_on_trigger_schedules?
+ connection.foreign_keys(:ci_trigger_schedules).include?("ci_triggers")
+ end
end