method

foreign_key

rails latest stable - Class: ActiveRecord::ConnectionAdapters::ColumnMethods::Table
foreign_key(*args, **options)
public

Adds a foreign key to the table using a supplied table name.

t.foreign_key(:authors)
t.foreign_key(:authors, column: :author_id, primary_key: "id")

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