0
votes

Help!!

I am trying to push my production code to heroku but for some reason heroku run rake db:migrate command doesn't work. It gives me this error:

Migrating to RemoveMealPlanFromOrders (20150125085531)
== 20150125085531 RemoveMealPlanFromOrders: migrating =========================
-- remove_reference(:orders, :mealplan, {:index=>true})
PG::Error: ERROR:  column "mealplan_id" of relation "orders" does not exist
: ALTER TABLE "orders" DROP "mealplan_id"
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  column "mealplan_id" of relation "orders" does not exist
: ALTER TABLE "orders" DROP "mealplan_id"/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `exec'
...

I have desperately tried everything including manually deleting the migration file the error references, running rake db:reset, and resetting heroku's database and even restarting the heroku app, but to no avail. I would infinitely appreciate if anyone could offer a solution to this error. I need to meet a deadline to submit this production code.

Thanks in advance!!!

2
you have a migration missing (where you added mealplan_id) - Anthony
what do you mean i have a migration missing? mealplan_id doesn't exist anymore as I removed its association with another model. - Abhas Arya
The error is saying that the reference has already been removed in POstgres - Brennan

2 Answers

2
votes

Heroku Postgres is the SQL database service run by Heroku that is provisioned and managed.before pushing code-repository from git to Heroku you need to migrate database by following command.

heroku run rake db:migrate --app your_app_name.

after db-migaration.

git push heroku master

if you have done any changes to database make sure of migrating database before pushing into heroku.

1
votes

I figured out the problem. Apparently I had removed the conflicting migration on my local machine but forgot to run the command git push heroku. Once I did that I was able to do heroku run rake db:migrate without a problem.

Happy coding!