# Question about create\_table

**URL:** <https://www.ruby-forum.com/t/question-about-create-table/170802>\
**Category:** Rails\
**Created:** [June 23, 2009, 12:46am UTC](https://www.ruby-forum.com/t/question-about-create-table/170802 "2009-06-23T00:46:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiahong\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/3d9bf3/32.png) [@Xiahong\_G](https://www.ruby-forum.com/u/Xiahong_G)\
**Post date:** [June 23, 2009, 12:46am UTC](https://www.ruby-forum.com/t/question-about-create-table/170802/1 "2009-06-23T00:46:16Z")

</div>

Hi everyone,

I am a newb. I have one question about following code:

def self.up  
create\_table :order\_histories do |t|  
t.column :order\_id, :integer, :null =\> false  
t.column :created\_at, :timestamp  
t.column :notes, :text  
end  
end

so, create\_table is a method which takes the name of table  
(order\_histories) and a code block. I wonder what’s the data type of  
t?? where can I find it?

xiahong

---

<div class="post-metadata">

**Author:** ![Xiahong\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/3d9bf3/32.png) [@Xiahong\_G](https://www.ruby-forum.com/u/Xiahong_G)\
**Post date:** [June 23, 2009, 12:56am UTC](https://www.ruby-forum.com/t/question-about-create-table/170802/2 "2009-06-23T00:56:48Z")

</div>

> so, create\_table is a method which takes the name of table  
> (order\_histories) and a code block. I wonder what’s the data type of  
> t?? where can I find it?

Couple of ways you could figure it out… the hack-ish way would be  
to add the following to your migration and then run it:

puts t.class

Or, look at the source for create\_table in activerecord/lib/  
active\_record/connection\_adapters/abstract/schema\_statements.rb

That says it’s a TableDefinition object.

-philip

---

<div class="post-metadata">

**Author:** ![Xiahong\_G](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/3d9bf3/32.png) [@Xiahong\_G](https://www.ruby-forum.com/u/Xiahong_G)\
**Post date:** [June 23, 2009, 5:10am UTC](https://www.ruby-forum.com/t/question-about-create-table/170802/3 "2009-06-23T05:10:38Z")

</div>

thx

2009/6/22 Philip H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
