Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Peter Brown
7,953 Pointsrake db:migrate - rake aborted bc SQLite3 table already exists?
I'm trying to do the first db:migrate steps in the todo list app track but I keep getting a "rake aborted!" error message. Here is the full error message:
railsapi:~/projects/odot (master *) $ rake db:migrate
== CreateTodoLists: migrating ================================================
-- create_table(:todo_lists)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table "todo_lists" already exists: CREATE TABLE "todo_lists" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "description" text, "created_at" datetime, "updated_at" datetime) /home/treehouse/projects/odot/db/migrate/20150402161626_create_todo_lists.rb:3:in `change'
ActiveRecord::StatementInvalid: SQLite3::SQLException: table "todo_lists" already exists: CREATE TABLE "todo_lists" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "description" text, "created_at" datetime, "updated_at" datetime)
/home/treehouse/projects/odot/db/migrate/20150402161626_create_todo_lists.rb:3:in `change'
SQLite3::SQLException: table "todo_lists" already exists
/home/treehouse/projects/odot/db/migrate/20150402161626_create_todo_lists.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Any help would be huge!
1 Answer

Geoff Parsons
11,679 PointsLooks like, as the error is stating, the table "todo_lists" already exists and a migration is trying to create it. Make sure you don't have multiple migrations that try to create that table. If you're trying to add fields to it make sure you use a change
method in your migration and call add_column
or one of the related methods to make changes (in other words don't try to re-create the table to make changes).
It could also be that your migration versions have gotten mixed up and it's just trying to re-run the previous migration that creates that table. To test that you can drop dropping the database and starting over with your migrations. This isn't ideal and is not something you would want to do with production-level data but in development you can always do that with the following:
rake db:drop db:create db:migrate
If that completes successfully then you should be good to go. Hope that helps!
Derek Lin
1,563 PointsDerek Lin
1,563 Pointshow come rollback doesn't delete the table created?
also when would you use each of these?