2015-01-27 88 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之前遷移數據庫。

相關問題