Question

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'
Was it helpful?

Solution

The SQlite error is showing that you already create email field to users table.

ADD "email" varchar(255) DEFAULT '' NOT NULL. so try to use "different column name"

or remove old migration.

def change 
  remove_column  :users, :email, <type>
end

after that use this migration

def up
  add_column :users, :email, :string
end


def down
  remove_column :users, :email, :string
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top