I have a rails application which is running on different databases depends on client preferences. I have a "catalog_item_specifications" table which has a column "bec_id". The type of the column is string. Now I want to change the type of the column to integer. When I write:
change_column :catalog_item_specifications, :bec_id, :integer
It works fine on MySQL but failed on postgres. So according to this post: Rails - gmaps4rails gem on postgres I changed my migration to the following:
connection.execute(%q{
alter table catalog_item_specifications
alter column bec_id
type integer using bec_id::integer
})
It now work on Postgres but failed on MySQL. I need a solution (without dropping and re-adding) which will work for both.