I ran into a snag the other night when running my Rails migrations on my production MySQL database. None of my decimal columns had any scale (decimal places)! This problem didn’t happen in development running sqlite.
I fixed it by running another migration that specified the precision and scale for each decimal column. However, I haven’t worked out the best way to deal with this. I’ll probably switch my development db from sqlite to MySQL, but how do I verify the columns are correct? I could write a test for each model that validated each value had decimals after saving, but then I have to remember to update the test when I add or change a column. I could query MySQL to get the column type, but that will only work for MySQL. There doesn’t seem to be a way to get the metadata from ActiveRecord, but I’ll have to look deeper.
Suggestions are welcome. When I finally do get something figured out, I’ll update this post.