Commit c4067ed6 authored by Z.J. van de Weg's avatar Z.J. van de Weg

Only remove FK if it exists

parent a8901ce6
---
title: Remove foreigh key on ci_trigger_schedules only if it exists
merge_request:
author:
......@@ -4,10 +4,20 @@ class RemoveForeighKeyCiTriggerSchedules < ActiveRecord::Migration
DOWNTIME = false
def up
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment