Typecast values on change_column for postgresql

25 views
Skip to first unread message

Gabriel Sobrinho

unread,
May 25, 2012, 8:41:13 AM5/25/12
to rubyonra...@googlegroups.com
Hello,

Currently if you have a string column that have only number values (think a year column using string by mistake) and you want to change to integer, you can't.

If you apply this monkey-patch will be possible: https://gist.github.com/1393441


Note: if some value can't be casted by postgresql (if have a letter for example), the migration will fail as expected.

I think this is the expected behavior on change_column and I'm not sure but I guess mysql already does that.


What you think?

Gabriel Sobrinho

unread,
Oct 1, 2012, 3:28:48 PM10/1/12
to rubyonra...@googlegroups.com
No opinions about that?

Luís Ferreira

unread,
Oct 1, 2012, 4:56:18 PM10/1/12
to rubyonra...@googlegroups.com
It is a useful functionality. Looks good to me.

Thumbs up.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/rb1V8G9tj_sJ.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.

Cumprimentos,
Luís Ferreira



Reply all
Reply to author
Forward
0 new messages