views:

27

answers:

1

I can't seem to figure this one out by searching Google.

I have an existing database which has some columns with the type of double, what would I write in my rails migration to create an equivalent column type? It's a relatively old database and there maybe a more suitable datatype to use completely, but I wanted to see what others thought.

I was going to use the type of :decimal, is this the best choice?

Thoughts?

+1  A: 

There's no specific type for double, Rails tries to be smart about it:

The numeric (integer/decimal/float) column definitions use the :limit option for the number of bytes in an integer column type, and the :scale/:precision options for floats.

(precision is the number of significant digits; scale is how many of these fall after the decimal point.)

Andrew Vit