There's a function called index_exists?
in ActionRecord, but no foreign_key_exists?
on Rails 4.2.7.
So when I call remove_foreign_key :parties, :franchise_groups
on some databases it breaks.
What should I use?
Update
My code
class RemoveForeignKey < ActiveRecord::Migration
def up
if foreign_key_exists?(:parties, :franchise_groups)
remove_foreign_key :parties, :franchise_groups
end
end
end
gives the error
== 20161107163800 RemoveForeignKey: migrating =================================
-- foreign_key_exists?(:parties, :franchise_groups)
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `foreign_key_exists?' for #<RemoveForeignKey:0x00000007ea0b58>
/home/rje/.rvm/gems/ruby-2.3.0/gems/activerecord-4.2.7/lib/active_record/migration.rb:664:in `block in method_missing'