Hi I have a rails 3 app that has been using postgres database up until now. I''m in the processing to switching to mysql so that I can avail amazon''s rds. I have noticed when running my tests that in all my models that should have decimals values the values are being rounded to integers. I think the problem is that the migrations don''t set :precision and :scale values for decimal values which seem to be needed for mysql. Looking at the tables directly this seems to be the case Is the a better solution to this problem than editing all the migration files? Any pointer would be great appreciated -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2011-Feb-08 15:33 UTC
Re: migrating db from postgres to mysql rounding problems
Conor Nugent wrote in post #980324:> I have a rails 3 app that has been using postgres database up until > now. I''m in the processing to switching to mysql so that I can avail > amazon''s rds. I have noticed when running my tests that in all my > models that should have decimals values the values are being rounded > to integers. > > I think the problem is that the migrations don''t set :precision > and :scale values for decimal values which seem to be needed for > mysql. Looking at the tables directly this seems to be the case > > Is the a better solution to this problem than editing all the > migration files? > > Any pointer would be great appreciatedI wouldn''t be surprised that there are differences in the behavior between decimal types between different databases. So yes, I''d say the easiest fix to would be to specify the precision and scale in the migrations, which should have been done to begin with. An alternative to editing all the existing migration files would be to create a new migration and modify all the affected tables/columns there. That would keep your migrations moving forward. I always prefer to specify precision and scale for all my decimal columns. It helps to alleviate this problem, and makes the intent clear for later reference as well. -- Posted via http://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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.