1

when I go to my http://localhost:3000/ I am getting the following:

ActiveRecord::PendingMigrationError

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

Extracted source:

# Raises <tt>ActiveRecord::PendingMigrationError</tt> error if any migrations are pending.
def check_pending!(connection = Base.connection)
  raise ActiveRecord::PendingMigrationError if ActiveRecord::Migrator.needs_migration?(connection)
end
def load_schema_if_pending!

Also, when I tried to to the heroku run rake db:migrate in the console, it said:

StandardError: An error has occurred, this and all later migrations canceled: PG::DuplicateColumn: ERROR: column "email" of relation "users" already exists

I am new to ruby and followed the devise tutorial by Mackenzie Child. It's my last step to complete my first ruby application.

I am excited and looking forward to your help! :)

2 Answers 2

1

In your console run rake db:migrate Make sure you in the project directory

Sign up to request clarification or add additional context in comments.

2 Comments

I might add, running heroku run rake db:migrate runs the migration on Heroku, not in your localhost. Errors like "PG::DuplicateColumn: ERROR: column "email" of relation "users" already exists" usually come from modifying the migrations name or version.
Unfortunately it didn't help. When I do that I get: "rake aborted! StandardError: An error has occurred, this and all later migrations canceled:" Ater that: "SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email" varchar DEFAULT '' NOT NULL" And then a lot of hundrets of lines about SQLite3 and activerecord
0

You used devise generator to prepare migration for your User model. Your model was already in place before and already had an email column. Devise-generated migration tries to create the same column and, expectedly, fails, that's the reason for the error you're seeing:

PG::DuplicateColumn: ERROR: column "email" of relation "users" already exists

To fix that just open your devise-generated migration and remove the line which looks something like this:

t.string :email...

Then run rake db:migrate.

UPDATE

Since your database seems to be out of sync with your migrations it might be advisable to recreate it from scratch.

Run

rake db:drop db:create db:migrate

Note that all database data will be destroyed.

4 Comments

I tried it and still get an error after rake db:migrate, which looks like this: rake aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::SQLException: duplicate column name: encrypted_password: ALTER TABLE "users" ADD "encrypted_password" varchar DEFAULT '' NOT NULL /Users/matthiascordes/.rvm/gems/ruby-2.3.1/gems/sqlite3-1.3.11/lib/sqlite3/database.rb:91:in initialize' /Users/matthiascordes/.rvm/gems/ruby-2.3.1/gems/sqlite3-1.3.11/lib/sqlite3/database.rb:91:in new' ...and so on
and also this instead: SQLite3::SQLException: no such table: users: ALTER TABLE "users" ADD "encrypted_password" varchar DEFAULT '' NOT NULL
I pushed everything up to github (commits). Is there an easy way to restore everything from there?
Make sure this works locally first and when it does just push a new commit with the correct code state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.