Is there a function in index_exists?
called index_exists?
but no foreign_key_exists?
on Rails 4.2.7.
Therefore, when I call remove_foreign_key :parties, :franchise_groups
in 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 an 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'
source share