aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
diff options
context:
space:
mode:
authorAlex Handley <ahandley@me.com>2016-04-16 13:26:05 +0100
committerAlex Handley <ahandley@me.com>2016-04-16 21:32:22 +0100
commitd9565811f075273fbc3318af173fe4a21e14ae58 (patch)
tree4d6b308b239ef97525a01aa494e912232b04080f /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
parentfa8602656edbf879430fffefc5efa11d253da003 (diff)
downloadrails-d9565811f075273fbc3318af173fe4a21e14ae58.tar.gz
rails-d9565811f075273fbc3318af173fe4a21e14ae58.tar.bz2
rails-d9565811f075273fbc3318af173fe4a21e14ae58.zip
[ci skip] docs for add_references index option
- Add link for finding the addional options for index. - Add example for unique index as this is a common requirement. - Add link in guide for index options.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 020d9bbdca..da0c961142 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -776,7 +776,8 @@ module ActiveRecord
# [<tt>:type</tt>]
# The reference column type. Defaults to +:integer+.
# [<tt>:index</tt>]
- # Add an appropriate index. Defaults to false.
+ # Add an appropriate index. Defaults to false.
+ # See #add_index for usage of this option.
# [<tt>:foreign_key</tt>]
# Add an appropriate foreign key constraint. Defaults to false.
# [<tt>:polymorphic</tt>]
@@ -796,6 +797,14 @@ module ActiveRecord
#
# add_reference(:products, :supplier, polymorphic: true, index: true)
#
+ # ====== Create a supplier_id column with a unique index
+ #
+ # add_reference(:products, :supplier, index: { unique: true })
+ #
+ # ====== Create a supplier_id column with a named index
+ #
+ # add_reference(:products, :supplier, index: { name: "my_supplier_index" })
+ #
# ====== Create a supplier_id column and appropriate foreign key
#
# add_reference(:products, :supplier, foreign_key: true)