I recently converted a string to a decimal in Rails using migrate and this works fine locally. I then pushed my application to heroku and got the following error:
Running `rake db:migrate` attached to terminal... up, run.9099
== ChangePriceToDecimal: migrating ===========================================
-- change_column(:products, :price, :decimal, {:precision=>8, :scale=>2})
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: column "price" cannot be cast automatically to type numeric
HINT: Specify a USING expression to perform the conversion.
: ALTER TABLE "products" ALTER COLUMN "price" TYPE decimal(8,2)
Here is the migrate file that I used:
class ChangePriceToDecimal < ActiveRecord::Migration
def change
change_column :products, :price, :decimal, precision: 8, scale: 2
end
end
Any idea what I can do to resolve this?
Thanks, T