mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
docs for create_table
and non-int primary keys. [ci skip]
This commit is contained in:
parent
55d9e494e8
commit
107526e809
1 changed files with 17 additions and 0 deletions
|
@ -120,6 +120,8 @@ module ActiveRecord
|
||||||
# [<tt>:id</tt>]
|
# [<tt>:id</tt>]
|
||||||
# Whether to automatically add a primary key column. Defaults to true.
|
# Whether to automatically add a primary key column. Defaults to true.
|
||||||
# Join tables for +has_and_belongs_to_many+ should set it to false.
|
# 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>]
|
# [<tt>:primary_key</tt>]
|
||||||
# The name of the primary key, if one is to be added automatically.
|
# 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.
|
# Defaults to +id+. If <tt>:id</tt> is false this option is ignored.
|
||||||
|
@ -163,6 +165,21 @@ module ActiveRecord
|
||||||
# name varchar(80)
|
# 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
|
# ====== Do not add a primary key column
|
||||||
#
|
#
|
||||||
# create_table(:categories_suppliers, id: false) do |t|
|
# create_table(:categories_suppliers, id: false) do |t|
|
||||||
|
|
Loading…
Reference in a new issue