2015-01-27 67 views
0

帮助!!Heroku run rake db:migrate not working

我想把我的生产代码推到heroku,但由于某种原因,heroku运行rake db:migrate命令不起作用。它给我这个错误:

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' 
... 

我已经拼命的一切,包括手动删除迁移文件中的错误引用,运行rake db:reset和重置Heroku的数据库,甚至重新启动Heroku的应用程序,但无济于事。如果有人能为这个错误提供解决方案,我将无限欣赏。我需要满足截止日期才能提交此生产代码。

在此先感谢!

+0

你有一个迁移缺失(你添加了mealplan_id) – Anthony 2015-01-27 01:43:14

+0

你是什么意思我有一个迁移失踪?随着我删除与另一个模型的关联,mealplan_id不再存在。 – 2015-01-27 01:45:37

+0

错误是说在POstgres中已经删除了该引用 – Brennan 2015-01-27 01:48:10

回答

1

我想出了这个问题。显然,我已经删除了本地机器上的冲突迁移,但忘记运行命令git push heroku。一旦我做到了,我就可以毫无问题地做heroku run rake db:migrate

快乐编码!

1

Heroku Postgres是由Heroku运行的SQL数据库服务,在配置和管理之前,在将代码库从git推送到Heroku之前,您需要通过以下命令迁移数据库。

heroku run rake db:migrate --app your_app_name.

db-migaration之后。

git push heroku master

如果你做对数据库做任何变更,确保推入的Heroku之前迁移数据库。

相关问题