How to create long integer or double precision database columns in Rails
2010-03-04

Rails doesn’t provide types to create long integer or double precision columns, however it can be done using the :limit parameter:

create_table :my_table do |t|
  t.integer :long_int_column, :limit => 8
  t.float :double_column, :limit => 53
end

8 and 53 are magic numbers. I normally generate the migration first and then modify the migration file to add the limit parameter.

This works for PostgreSQL and MySQL databases, but I haven’t tried any others.

Works on: Rails 2.3.5