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? -- 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/-/Sc4AlLJWqNQJ. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Gabriel Sobrinho
2012-Oct-01 19:28 UTC
Re: Typecast values on change_column for postgresql
No opinions about that? On Friday, May 25, 2012 9:41:13 AM UTC-3, Gabriel Sobrinho wrote:> > 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? >-- 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 rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Luís Ferreira
2012-Oct-01 20:56 UTC
Re: Re: Typecast values on change_column for postgresql
It is a useful functionality. Looks good to me. Thumbs up. On Oct 1, 2012, at 8:28 PM, Gabriel Sobrinho wrote:> No opinions about that? > > On Friday, May 25, 2012 9:41:13 AM UTC-3, Gabriel Sobrinho wrote: > 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? > > -- > 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 rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.Cumprimentos, Luís Ferreira -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.