Re: Longtext in a Migration

Peter De Berdt
2008-02-06T16:42:38Z

On 06 Feb 2008, at 17:38, Joe Peck wrote:

> 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?


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