aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-04-24 13:58:07 +0200
committerYves Senn <yves.senn@gmail.com>2015-04-24 13:58:07 +0200
commit107526e809ea2b6de8b2775ecf83e55d60833206 (patch)
treeb0b7a3bb1547f958a8eb149de5bf6719bcdb6a8b
parent55d9e494e896e7b041dc7c18df197d53690642b5 (diff)
downloadrails-107526e809ea2b6de8b2775ecf83e55d60833206.tar.gz
rails-107526e809ea2b6de8b2775ecf83e55d60833206.tar.bz2
rails-107526e809ea2b6de8b2775ecf83e55d60833206.zip
docs for `create_table` and non-int primary keys. [ci skip]
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb17
1 files changed, 17 insertions, 0 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 ecb4868c13..a59a5ac2ea 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -120,6 +120,8 @@ module ActiveRecord
# [<tt>:id</tt>]
# Whether to automatically add a primary key column. Defaults to true.
# Join tables for +has_and_belongs_to_many+ should set it to false.
+ #
+ # A Symbol can be used to specify the type of the generated primary key column.
# [<tt>:primary_key</tt>]
# The name of the primary key, if one is to be added automatically.
# Defaults to +id+. If <tt>:id</tt> is false this option is ignored.
@@ -163,6 +165,21 @@ module ActiveRecord
# name varchar(80)
# )
#
+ # ====== Change the primary key column type
+ #
+ # create_table(:categories_suppliers, id: :string) do |t|
+ # t.column :category_id, :integer
+ # t.column :supplier_id, :integer
+ # end
+ #
+ # generates:
+ #
+ # CREATE TABLE categories_suppliers (
+ # id varchar PRIMARY KEY,
+ # category_id int,
+ # supplier_id int
+ # )
+ #
# ====== Do not add a primary key column
#
# create_table(:categories_suppliers, id: false) do |t|