2012-06-13 97 views
0

我希望做我的應用程序,我在Heroku上運行遷移,但我得到這個錯誤:Heroku的運行耙分貝:遷移錯誤

Running `rake db:migrate` attached to terminal... up, run.1 
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7) 
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7) 
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7) 
Migrating to CreateUsers (20120525005302) 
Migrating to DeviseCreateUsers (20120611000411) 
== DeviseCreateUsers: migrating ============================================== 
-- create_table(:users) 
rake aborted! 
An error has occurred, this and all later migrations canceled: 

PGError: ERROR: relation "users" already exists 
: CREATE TABLE "users" ("id" serial primary key, "email" character varying(255) DEFAULT '' NOT NULL, "encrypted_password" character varying(255) DEFAULT '' NOT NULL, "reset_password_token" character varying(255), "reset_password_sent_at" timestamp, "remember_created_at" timestamp, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" timestamp, "last_sign_in_at" timestamp, "current_sign_in_ip" character varying(255), "last_sign_in_ip" character varying(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) 

Tasks: TOP => db:migrate 

我在我的github倉庫以下遷移文件

  1. 20120525005302_create_users.rb(裏面是空的,不知道如何刪除它)
  2. 20120611000411_devise_create_users.rb
  3. 20120613140535_create_authentications.rb

回答

2

看起來符合下列條件:

  • 20120525005302_create_users.rb將嘗試在數據庫中創建一個users表。
  • 20120611000411_devise_create_users.rb也將嘗試在數據庫中創建一個users表。
  • 您的數據庫目前已有一個users表格,因此遷移在第二次遷移時失敗。

要獲得users表在數據庫中正確對應20120611000411_devise_create_users.rb遷移,你可以做兩件事情之一:

  1. 回滾(或下降)的數據庫,然後運行遷移再次。 (如果它爲空,您可以刪除20120525005302_create_users.rb。)
  2. 修改您的20120611000411_devise_create_users.rb遷移,在執行任何其他操作之前刪除任何現有的users表。
  3. 修改您的20120611000411_devise_create_users.rb遷移如下:
    • 而是創建一個users表,修改現有的表。
    • 添加和修改數據庫組件對應

一般來說,如果你的應用程序處於「嬰兒狀態」,然後重新創建數據庫往往是建立的初始結構的快捷方式一個應用程序。但是,如果您的users表中已經有重要數據,那麼您需要保留該數據並通過修改20120611000411_devise_create_users.rb遷移繼續進行,以非破壞性方式更改數據庫。

參考

+0

我rollbacked所有的遷移,我沒有在第一遷移和我推everthing upp github把它仍然存在.. – SHUMAcupcake

+0

和everthing在schema.rb文件中看起來不錯.. https://gist.github.com/2926873 – SHUMAcupcake

+0

我現在已經刪除了遷移文件,仍然得到相同的錯誤。 – SHUMAcupcake

1

看起來你已經有表的用戶(可能是從create_users遷移)是device_create_users正在試圖重新

您可以通過修改create_device_users遷移只需添加你需要

另外,如果等領域的沒有用戶帶來全新的應用程序,你可以剛落,並嘗試重新運行的所有migraions

+0

廣東話我只是刪除我的應用程序和GitHub的RESP,移民..我該怎麼辦呢? – SHUMAcupcake

+1

的git RM 20120525005302_create_users.rb 混帳推起源主 Heroku的運行耙分貝:滴 Heroku的運行耙分貝:創建 Heroku的運行耙分貝:遷移 –

相關問題