I am working through chapter 10 of the Hartl book. In the conclusion of this chapter, we reset the heroku database and then migrate. However when I run:
heroku run rails db:migrate
I get an error:
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "password_digest_string" of relation "users" does not exist
: ALTER TABLE "users" DROP "password_digest_string"
Earlier in the tutorial, I removed a column called password_digest_string because it was named incorrectly and I didn't need it yet. It seems like rails is trying to delete the column again even though it isn't there anymore. I deleted the migration file that removed this column but it still is trying to drop it. What's also odd is that I've migrated the database several times since dropping that column and never had this issue until I reset it. Any suggestions?
EDIT:
here is my schema file:
ActiveRecord::Schema.define(version: 20170121224748) 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.boolean "admin", default: false
t.index ["email"], name: "index_users_on_email", unique: true
end
end
EDIT:
And my migrations in time-stamp order.
..._create_users.rb
class CreateUsers < ActiveRecord::Migration[5.0]
def change
create_table :users do |t|
t.string :name
t.string :email
t.timestamps
end
end
end
..._add_index_to_users_email.rb
class AddIndexToUsersEmail < ActiveRecord::Migration[5.0]
def change
add_index :users, :email, unique: true
end
end
..._add_password_digest_to_users.rb
class AddPasswordDigestToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :password_digest, :string
end
end
..._remove_columns.rb
class RemoveColumns < ActiveRecord::Migration[5.0]
def self.up
remove_column :users, :password_digest_string
end
end
..._add_remember_digest_to_users.rb
class AddRememberDigestToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :remember_digest, :string
end
end
..._add_admin_to_users.rb
class AddAdminToUsers < ActiveRecord::Migration[5.0]
def change
add_column :users, :admin, :boolean, default: false
end
end