如何删除Devise表来运行'rake db:migrate'?

时间:2013-04-10 21:16:56

标签: ruby-on-rails devise

我在Rails 3.2.12中为我的Web应用程序添加了设计。我成功运行了$ rails generate devise:install$ rails generate devise User

这是我运行$ rake routes时所得到的:

         new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
             user_session POST   /users/sign_in(.:format)       devise/sessions#create
     destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
            user_password POST   /users/password(.:format)      devise/passwords#create
        new_user_password GET    /users/password/new(.:format)  devise/passwords#new
       edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
                          PUT    /users/password(.:format)      devise/passwords#update
 cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
        user_registration POST   /users(.:format)               devise/registrations#create
    new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
   edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                          PUT    /users(.:format)               devise/registrations#update
                          DELETE /users(.:format)               devise/registrations#destroy
                     root        /                              pages#home
                    about GET    /about(.:format)               pages#about

当我尝试运行rake db:migrate时,我收到以下错误

 ==  DeviseCreateUsers: migrating ==============================================
 -- create_table(:users)
 rake aborted!
 An error has occurred, this and all later migrations canceled:

 SQLite3::SQLException: table "users" already exists: CREATE TABLE "users" ("id" INTEGER PRIMARY     KEY AUTOINCREMENT NOT NULL, "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password"    varchar(255) DEFAULT '' NOT NULL, "reset_password_token" varchar(255), "reset_password_sent_at"    datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0, "current_sign_in_at"    datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip"    varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)   /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in    `initialize' 

它告诉我我已经有了'用户'表。如果是这种情况,这个sql表在哪里?在此先感谢您的帮助!

1 个答案:

答案 0 :(得分:2)

我会查看您之前的迁移,看看是否有创建users表的迁移。如果是这样,也许删除该迁移。在任何情况下,我都会进入您的rails dbconsole并手动删除users表,然后再次运行rake db:migrate