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

Devise migrations canceled

I received the following error. when doing a rake db:migrate. The problem is with Add Device to Users I will keep checking Any ideas?

C:\Sites\projects\code\treebook>rake db:migrate
==  CreateStatuses: migrating =================================================
-- create_table(:statuses)
   -> 0.0040s
==  CreateStatuses: migrated (0.0060s) ========================================

==  DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
   -> 0.0390s
-- add_index(:users, :email, {:unique=>true})
   -> 0.0020s
-- add_index(:users, :reset_password_token, {:unique=>true})
   -> 0.0010s
==  DeviseCreateUsers: migrated (0.0450s) =====================================

==  AddUserIdToStatuses: migrating ============================================
-- add_column(:statuses, :user_id, :integer)
   -> 0.0020s
-- add_index(:statuses, :user_id)
   -> 0.0010s
-- remove_column(:statuses, :name)
   -> 0.0120s
==  AddUserIdToStatuses: migrated (0.0190s) ===================================

==  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 NULL

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

1 Answer

If I'm not mistaken, there's already an email column in your users table and Devise is trying to add it again. Try removing the email field step from the rake task.

This is the relevant part of the error message:

SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "em ail" varchar(255) DEFAULT '' NOT NULL

Hope it helps

Thank you Guilherme,

One question. How to remove email field from rake task?

I will search.

Thanks,

Chris