Module | Foreigner::ConnectionAdapters::Table |
In: |
lib/foreigner/connection_adapters/abstract/schema_definitions.rb
|
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
t.foreign_key(:people)
t.foreign_key(:people, :column => :sender_id)
t.foreign_key(:people, :column => :sender_id, :name => 'sender_foreign_key')
t.foreign_key(:people, :column => :sender_id, :primary_key => :person_id)
Adds a :foreign_key option to Table.references. If :foreign_key is true, a foreign key constraint is added to the table. You can also specify a hash, which is passed as foreign key options.
t.references(:goat, :foreign_key => true)
t.references(:goat, :foreign_key => {:dependent => :delete})
Note: No foreign key is created if :polymorphic => true is used.
Remove the given foreign key from the table.
t.remove_foreign_key :companies
remove_foreign_key :column => :branch_id
remove_index :name => :party_foreign_key