Error ActiveRecord::PendingMigrationError
<p>I am following Michael Hartl's book and I am getting this error when I run the server: </p>

<p><img src="https://i.stack.imgur.com/Om4yH.png" alt="enter image description here"></p>

<p>I am getting ActiveRecord::PendingMigrationError when I run the server, this shows up:</p>

<p>Migrations are pending. To resolve this issue, run: bin/rails  db:migrate RAILS_ENV=development</p>

<p>Please I've been stuck in this error for so long.</p>

<p>When I type <code>$ RAILS_ENV=development rake db:migrate</code> I get this error:</p>

<blockquote>
  <p>== 20161209073230 AddActivationToUsers: migrating =============================
  -- add_column(:users, :activation_digest, :string) rake aborted! StandardError: An error has occurred, this and all later migrations
  canceled:</p>
  
  <p>SQLite3::SQLException: duplicate column name: activation_digest: ALTER
  TABLE "users" ADD "activation_digest" varchar
  (required)>' Tasks: TOP => db:migrate (See full trace by running task
  with --trace)</p>
</blockquote>

<p>test/mailers/previews/user_mailer_preview.rb</p>

<blockquote>
  <p>UserMailerPreview &lt; ActionMailer::Preview</p>
  
  <p># Preview this email at
  <a href="http://localhost:3000/rails/mailers/user_mailer/account_activation" rel="nofollow noreferrer">http://localhost:3000/rails/mailers/user_mailer/account_activation</a><br>
  def account_activation
      user = User.first
      user.activation_token = User.new_token
      UserMailer.account_activation(user)   end</p>
  
  <p># Preview this email at
  <a href="http://localhost:3000/rails/mailers/user_mailer/password_reset" rel="nofollow noreferrer">http://localhost:3000/rails/mailers/user_mailer/password_reset</a>   def
  password_reset
      UserMailer.password_reset   end</p>
  
  <p>end</p>
</blockquote>

<p>Schema.rb:</p>

<pre><code># This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20161123005710) do

  create_table "users", force: :cascade do |t|
    t.string   "name"
    t.string   "email"
    t.datetime "created_at",        null: false
    t.datetime "updated_at",        null: false
    t.string   "password_digest"
    t.string   "remember_digest"
    t.string   "activation_digest"
    t.index ["email"], name: "index_users_on_email", unique: true   end

end
</code></pre>

<p>Latest migration is
 db/migrate/[timestamp]_add_activation_to_users.rb:</p>

<pre><code>class AddActivationToUsers &lt; ActiveRecord::Migration[5.0]
  def change
    add_column :users, :activation_digest, :string
    add_column :users, :activated, :boolean, default: falserao
    add_column :users, :activated_at, :datetime
  end
end
</code></pre>