I am new to RoR and I keep getting this error message:
$ rake db:migrate
== CreateUsers: 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, "name" varchar(255), "email" varchar
(255), "created_at" datetime, "updated_at" datetime)
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I've been searching for a solution for 3 days, but I cannot seem to find anything that works for me.
Thank you in advance for your help :) PS - I am running off Windows.
Not sure if you are following Michael Hartl's tutorial on RoR.
But someone has said there's a problem in the steps of the tutorial http://archive.railsforum.com/viewtopic.php?id=44944
rake db:drop:all
<---------- will wipe everything then runrake db:migrate
again should fix the problem.Good Luck
Because the table already exists, you need to delete/remove it before executing the migration.
Easy, GUI way to do this is with the SQLite Database Browser (http://sourceforge.net/projects/sqlitebrowser/).
Click the button with the Table-X icon. Choose User Table click Delete.
Then run
rake db:migrate
Bada boom bada bing
I had a similar problem, then i did =>
rake db:drop
=>rake db:create
=>rake db:migrate
worked perfectly.
table "users" already exists
seems to be the problem. Have you tried to manually remove the table from your database with some SQLITE admin tool?Or you can include a remove table in your migration script (should be called create_users.rb inside your db/migrate folder). Inside
def up
insertdrop_table :users
:Oh and I remember from my RoR time that the table name "Users" can cause problems later on. Might be this is related.