Question about create_table

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

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

thx

2009/6/22 Philip H. [email protected]