How would I go about changing the decimals and length attributes of a float column in my Rails 3 migration file. I have tried the following w/ no success:
class IncreaseLatitudeLongitudeFieldLengths < ActiveRecord::Migration
def self.up
change_column :skateparks, :latitude, :float, {:length => 15, :decimals => 12}
change_column :skateparks, :longitude, :float, {:length => 15, :decimals => 12}
end
def self.down
change_column :skateparks, :latitude, :float, {:length => 0, :decimals => 0}
change_column :skateparks, :longitude, :float, {:length => 0, :decimals => 0}
end
end
Personal experience what works best (since MySQL/sqlite sometimes refuses changes to columns): Create a new column, copy the data, delete the old column, rename the new column.
EDIT: On the second look
:float, { :length => 15, :decimals => 12 }seems to be wrong. I assume you meant::decimal, :precision => 15, :scale => 12?