jpalmieri / brewery

Make and share homebrew recipes (ones that actually make beer, irl)
http://brewery-jpalmieri.herokuapp.com
0 stars 0 forks source link

Numeric field overflow error on yeast attenuation #18

Closed jpalmieri closed 9 years ago

jpalmieri commented 9 years ago

Yeast attenuation is a percent, so I originally migrated the attenuation column as a decimal less than 1, e.g., "0.75" for 75%. However, the implementation of this turned out to be more of a headache than I imagined, so I began storing the attenuation as the percent (e.g., "75") straight from the form without first processing it into a decimal. I didn't make any additional migrations to account for this.

When adding recipes in Heroku, I encountered this error: DETAIL: A field with precision 4, scale 3 must round to an absolute value less than 10^1.

It seems that the yeast attenuation, which currently has precision 4, scale 3, isn't working in Postgres because of it's stricter typing (whereas SQLite treats decimals like numerics).

The short term solution is to run a new migration that will change the precision to 4 and the scale to 2, e.g., "75.25", nothing higher than "99.99").

The long term solution, or more of a safeguard to prevent these from popping up after pushing to production, is to change the dev and test db's to Postgres.

jpalmieri commented 9 years ago

It may also be necessary to review the precision and scale of the grain and hop weights.

should also probably use max's in the input fields for all decimals.