I'm new to ruby on rails and am having difficulty understanding the error I'm seeing here and I can't find it when I'm searching.
I'm adding Devise to my application and would like to make it confirmable. So I added Devise to the gem file, bundle install, added line to development.rb, did the root'home#home' thing, and added the notification/alert to layout. No issues.
model/user.rb
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :validatable
end
migration file
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
# t.integer :sign_in_count, default: 0, null: false
# t.datetime :current_sign_in_at
# t.datetime :last_sign_in_at
# t.inet :current_sign_in_ip
# t.inet :last_sign_in_ip
# Confirmable
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps null: false
end
add_index :users, :email, unique: true
add_index :users, :reset_password_token, unique: true
add_index :users, :confirmation_token, unique: true
add_index :users, :unlock_token, unique: true
end
end
Now when I run $ rails db:migrate
I get the error
== 20180816012427 DeviseCreateStudents: migrating =============================
-- create_table(:users)
-> 0.0021s
-- add_index(:users, :email, {:unique=>true})
-> 0.0013s
-- add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0013s
-- add_index(:users, :confirmation_token, {:unique=>true})
-> 0.0016s
-- add_index(:users, :unlock_token, {:unique=>true})
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table users has no column named unlock_token: CREATE UNIQUE INDEX "index_users_on_unlock_token" ON "users" ("unlock_token")
I'm still learning what different errors mean but wasn't able to find what this means. Thanks for taking a look.