Longtext in a Migration

Hey, I need to use “longtext” as a data type in a migration.

It works when I make create a table, like this:
create_table :joes do |t|
t.column :lots_o_content, :longtext
end

But if I try to add it to another table in a later migration, like this:
add_column :sams, :lots_o_other_content, :longtext

Then I get this error when trying to run the migration:
– add_column(:sams, :lots_o_other_content, :longtext)
rake aborted!
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]

My question is, how can I add a column of type “longtext” in a
migration?

Never mind, I found out how to do it.

I just put this in the migration instead of using “add_column”:
execute “ALTER TABLE sams ADD COLUMN lots_o_other_content LONGTEXT”

On 06 Feb 2008, at 17:38, Joe P. wrote:

Then I get this error when trying to run the migration:
– add_column(:sams, :lots_o_other_content, :longtext)
rake aborted!
You have a nil object when you didn’t expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
My question is, how can I add a column of type “longtext” in a
migration?

You can’t, as it isn’t one of the column types, use :text, which is
what you want for a text blob:

http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/
TableDefinition.html

Best regards

Peter De Berdt