From 107526e809ea2b6de8b2775ecf83e55d60833206 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Fri, 24 Apr 2015 13:58:07 +0200 Subject: docs for `create_table` and non-int primary keys. [ci skip] --- .../connection_adapters/abstract/schema_statements.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'activerecord/lib/active_record') 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 # [:id] # 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. # [:primary_key] # The name of the primary key, if one is to be added automatically. # Defaults to +id+. If :id 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| -- cgit v1.2.3