method

foreign_key_exists?

Importance_1
v6.1.7.7 - Show latest stable - 0 notes - Class: ActiveRecord::ConnectionAdapters::SchemaStatements
foreign_key_exists?(from_table, to_table = nil, **options) public

Checks to see if a foreign key exists on a table for a given foreign key definition.

# Checks to see if a foreign key exists.
foreign_key_exists?(:accounts, :branches)

# Checks to see if a foreign key on a specified column exists.
foreign_key_exists?(:accounts, column: :owner_id)

# Checks to see if a foreign key with a custom name exists.
foreign_key_exists?(:accounts, name: "special_fk_name")
Show source
Register or log in to add new notes.