aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/4_2_release_notes.md
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2014-06-12 08:42:00 +0200
committerYves Senn <yves.senn@gmail.com>2014-06-26 22:04:17 +0200
commita5b3f372ab30e043d25b25b05e603e6ed33c0ee9 (patch)
treed766406aaefddedfc108297354e73bef80d95b06 /guides/source/4_2_release_notes.md
parent24e1aefb4b2d7b2b4babfd4bae1e9e613283b003 (diff)
downloadrails-a5b3f372ab30e043d25b25b05e603e6ed33c0ee9.tar.gz
rails-a5b3f372ab30e043d25b25b05e603e6ed33c0ee9.tar.bz2
rails-a5b3f372ab30e043d25b25b05e603e6ed33c0ee9.zip
fk: add docs
Diffstat (limited to 'guides/source/4_2_release_notes.md')
-rw-r--r--guides/source/4_2_release_notes.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/guides/source/4_2_release_notes.md b/guides/source/4_2_release_notes.md
index dd484ccee2..ef294f55d7 100644
--- a/guides/source/4_2_release_notes.md
+++ b/guides/source/4_2_release_notes.md
@@ -25,6 +25,31 @@ guide.
Major Features
--------------
+### Foreign key support
+
+The migration DSL now supports adding and removing foreign keys. They are dumped
+to `schema.rb` as well. At this time, only the `mysql`, `mysql2` and `postgresql`
+adapters support foreign keys.
+
+```ruby
+# add a foreign key to `articles.author_id` referencing `authors.id`
+add_foreign_key :articles, :authors
+
+# add a foreign key to `articles.author_id` referencing `users.lng_id`
+add_foreign_key :articles, :users, column: :author_id, primary_key: "lng_id"
+
+# remove the foreign key on `accounts.branch_id`
+remove_foreign_key :accounts, :branches
+
+# remove the foreign key on `accounts.owner_id`
+remove_foreign_key :accounts, column: :owner_id
+```
+
+See the API documentation on
+[add_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_foreign_key)
+and
+[remove_foreign_key](http://api.rubyonrails.org/v4.2.0/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-remove_foreign_key)
+for a full description.
Railties