Module Foreigner::ConnectionAdapters::Table
In: lib/foreigner/connection_adapters/abstract/schema_definitions.rb

Methods

Public Instance methods

Adds a new foreign key to the table. to_table can be a single Symbol, or an Array of Symbols. See SchemaStatements#add_foreign_key

Examples
Creating a simple foreign key
 t.foreign_key(:people)
Defining the column
 t.foreign_key(:people, :column => :sender_id)
Creating a named foreign key
 t.foreign_key(:people, :column => :sender_id, :name => 'sender_foreign_key')
Defining the column of the to_table.
 t.foreign_key(:people, :column => :sender_id, :primary_key => :person_id)

Remove the given foreign key from the table.

Examples
Remove the suppliers_company_id_fk in the suppliers table.
  change_table :suppliers do |t|
    t.remove_foreign_key :companies
  end
Remove the foreign key named accounts_branch_id_fk in the accounts table.
  change_table :accounts do |t|
    t.remove_foreign_key :column => :branch_id
  end
Remove the foreign key named party_foreign_key in the accounts table.
  change_table :accounts do |t|
    t.remove_index :name => :party_foreign_key
  end

[Validate]