method

foreign_key_exists?

rails latest stable - Class: ActiveRecord::ConnectionAdapters::Table

Method not available on this version

This method is only available on newer versions. The first available version (v5.0.0.1) is shown here.

foreign_key_exists?(*args)
public

Checks to see if a foreign key exists.

t.foreign_key(:authors) unless t.foreign_key_exists?(:authors)

See {connection.foreign_key_exists?}[rdoc-ref:SchemaStatements#foreign_key_exists?]