sgx
sgx

Reputation: 1317

Bundle Exec Rake DB Migrate

I have been getting this error when I run bundle exec rake db:migrate for a basic RoR website. I am a beginner and found similar errors on this site and Treehouse but nothing with the specific second half of this error (from the NOT NULLC onward). I am still not sure how to resolve this - can anyone advise? I am running this on windows.

SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "em
ail" varchar(255) DEFAULT '' NOT NULLC:/Sites/code/omrails-master/db/migrate/201
30804201341_add_devise_to_users.rb:5:in `block in up' 

Upvotes: 0

Views: 2412

Answers (2)

Agis
Agis

Reputation: 33626

I guess it happens because you already have the email column in your users table (a previous migration added it, propably that created the table) and the Devise migration you're running (201 30804201341_add_devise_to_users.rb) is trying to re-add it. Is that the case?

If so, open the migration file which first creates the users table and remove the line that creates the email column (it looks something like t.string :email). Close your Rails server, then do the following.

$ bundle exec rake db:drop
$ bundle exec rake db:create
$ bundle exec rake db:migrate

Upvotes: 1

Gage Shaeffer
Gage Shaeffer

Reputation: 99

I came across this problem when first starting out. I always solved it by just reseting the database. You already have a column created so reseting it will probably work.

run

bundle exec rake db:reset

than

bundle exec rake db:create

and finally

bundle exec rake db:migrate

Upvotes: 0

Related Questions