Flowdock
method

foreign_key_exists?

Importance_1
v5.2.3 - Show latest stable - 0 notes - Class: ActiveRecord::ConnectionAdapters::SchemaStatements
foreign_key_exists?(from_table, options_or_to_table = {}) 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.