I've had the hardest time deploying my application to heroku. When I've try running RAILS_ENV=production bundle exec rake db:migrate
I wind up getting an error stating
PG::DatatypeMismatch: ERROR: column "downtown_id" cannot be cast automatically to type integer
HINT: You might need to specify "USING downtown_id::integer"
First thing I tried was this
def change
remove_column :properties, :downtown_id
add_column :properties, :downtown_id, :integer
end
No luck.
Then I tried this. (found from here).
def change
change_column :properties, :downtown_id, 'integer USING CAST(downtown_id AS integer)'
end
Still no luck. :(
Is there anything I need to do after I run these migrations on my dev environment first before i can try running them on a RAILS_ENV=production bundle exec rake db:migrate
?
I don't know what to do, and everything i've looked at points to the things i've already tried.
Try using this syntax:
def change
change_column :properties, :downtown_id, :integer, using: 'CAST(downtown_id AS integer)'
end