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! While you're at it, check out some resources Treehouse students have shared here.

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

Ruby

an error on 'rake db:migrate'

c:\treebook>rake db:migrate == DeviseCreateUsers: migrating ============================================== -- create_table(:users) -> 0.0520s -- add_index(:users, :email, {:unique=>true}) -> 0.0050s -- add_index(:users, :reset_password_token, {:unique=>true}) -> 0.0000s == DeviseCreateUsers: migrated (0.0600s) =====================================

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

SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "em ail" varchar(255) DEFAULT '' NOT NULLc:/treebook/db/migrate/20130531081324_add_d evise_to_users.rb:5:in block in up' c:/treebook/db/migrate/20130531081324_add_devise_to_users.rb:3:inup' C:in `migrate' Tasks: TOP => db:migrate (See full trace by running task with --trace)

I don't understand why I have this error, since I had not implemented this command yet. :(

Please give me your hands if you know any solution. Thank you!

2 Answers

Most probably your you have two migrations 0130531081324_add_d evise_to_users.rb and c:/treebook/db/migrate/20130531081324_add_devise_to_users.rb in your migrations directory and they both contain the same information of adding a column email. Now when the first migration while migrating will create an email column, the second migration will also try to create a column called email but in a table a column with the same name can not exist, thus it is giving this error.

Try looking at both the file, if the content within them is actually same, delete one of them and if the content is not same delete from either one of them the line which adds the column to the table

Thanks! I found and deleted that rb!

It says "em ail" instead of "email"... could there be a typo in the table names?