我的應用在生產環境中工作正常,但是當我轉移到生產並運行'heroku run rake db:migrate'時,我收到以下錯誤:Heroku/Rails:PG :: Undefined Table:error「[tablename]」在heroku rails遷移中不存在
PG::UndefinedTable: ERROR: table "applications" does not exist
Migrating to DropApplications (20160509013805)
(0.8ms) BEGIN
== 20160509013805 DropApplications: migrating =================================
-- drop_table(:applications)
(1.1ms) DROP TABLE "applications"
(0.5ms) ROLLBACK
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: table "applications" does not exist
: DROP TABLE "applications"
但是,在我的數據庫中有一個'應用程序'表。當我放棄,然後在前一天重新制作應用程序腳手架時,這個下降可能與此有關。我該如何解決?
create_table "applications", force: :cascade do |t|
t.string "name"
t.string "gender"
t.date "date_of_birth"
t.string "gpa"
t.text "essay"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
所以,當我運行運行rake:DB設置,我看到了以下結果:
Status Migration ID Migration Name
--------------------------------------------------
up 20160505200754 ********** NO FILE **********
up 20160508234634 Create users
up 20160508234945 Add devise to users
up 20160509013805 ********** NO FILE **********
up 20160509014328 ********** NO FILE **********
20160509014911 Create applications
兩個「創建應用程序,」我試圖刪除之前。因此,我嘗試耙一下heroku數據庫,如下所示:$ heroku run rake --trace db:migrate VERSION = 20151127134901但我仍然遇到「drop tables」的錯誤 - 嘗試執行20160509013805遷移。我如何在沒有文件的地方完全刪除這些遷移,因此它不會嘗試掠過這些遷移?先謝謝你。
對此有幫助嗎? http://stackoverflow.com/a/34321825/981616 – uday
這有助於我,並把我放在正確的軌道上......我想。我只是更新了原來的帖子,如果你可以 –
添加了答案,請檢查並讓我知道。 – uday