When I write rails db:migrate
, I get this error:
bundle exec rake db:migrate
== 20161209073230 AddActivationToUsers: migrating ============================= -- add_column(:users, :activation_digest, :string) rake aborted! StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: duplicate column name: activation_digest: ALTER TABLE "users" ADD "activation_digest" varchar
Here's my user table:
create_users.rb
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps null: false
end
end
end
This is my add_activation_to_users.rb
:
class AddActivationToUsers < ActiveRecord::Migration
def change
add_column :users, :activation_digest, :string
add_column :users, :activated, :boolean, default: false
add_column :users, :activated_at, :datetime
end
end
users
table, it might be already having a column namedactivation_digest
which you are again trying to add with migration version20161209073230
. – dp7rails console
- useUser.column_names
, if you have alreadyactivation_digest
, then you don't need to add it again. – dp7