Migration: updating a column

1 view
Skip to first unread message

Eric Yen

unread,
Jul 29, 2010, 9:03:53 AM7/29/10
to Ruby on Rails: Talk
Hi,

Is there a way to "update" a column?

Here's what I mean:
I have a column name "item" in table "products" of type "integer"
Now I want to update the column to have the option ":null => false"

So far, the only way I have found is to remove it and re-add it, but
obviously that is quite dumb.

Ar Chron

unread,
Jul 29, 2010, 9:19:23 AM7/29/10
to rubyonra...@googlegroups.com
Have you tried change_column in a migration?

http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
--
Posted via http://www.ruby-forum.com/.

Eric Yen

unread,
Jul 29, 2010, 10:42:37 AM7/29/10
to Ruby on Rails: Talk
Thanks.

I was under the impression that change_column was only for renaming.

Colin Law

unread,
Jul 29, 2010, 3:54:55 PM7/29/10
to rubyonra...@googlegroups.com
On 29 July 2010 15:42, Eric Yen <er...@ericyen.com> wrote:
> Thanks.
>
> I was under the impression that change_column was only for renaming.

Please don't top post on this list. Thanks.
rename_column is for renaming, change_column is for changing the
attributes of the col.

Column

>
>
> On Jul 29, 9:19 am, Ar Chron <li...@ruby-forum.com> wrote:
>> Have you tried change_column in a migration?
>>
>> http://api.rubyonrails.org/classes/ActiveRecord/Migration.html
>> --
>> Posted viahttp://www.ruby-forum.com/.
>

> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages