Migrations Are Pending; Run 'Bin/Rake Db:Migrate Rails_Env=Development' to Resolve This Issue [Unable to Proceed]

Getting: Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue. after cloning and migrating the project

Interesting. Did you run rake db:create? Assuming you are using sqlite3, do this:

      rm -f db/*.sqlite3
rake db:create
RAILS_ENV=development bundle exec rake db:migrate
rails s -e development

Also, can you list the contents of your config/database.yml file?

Edit: Warning! Obviously, you will lose your existing data.

Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development error when running as server

Migration files live in the db/migrate directory, and their names look like this:

20150121164407_create_comments.rb

From your comment, it looks like inside your db/migrate directory, you have several migrations with the same “basic” name create_comments (and probably different timestamps).
You need to remove one of those duplicated files.

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

Hay, in my case, i resolved this problem telling to docker execute some bash commands in the docker-compose.yml. Like:

In your docker-compose:

# your_app_path/docker-compose.yml
...
web:
build:
...
command: bash -c "build-scripts/container/web"
...

When your docker 'ups', the build-scripts/container/web will be executed.

Your Dockerfile, will be called on docker-compose build, you should not execute commands in this file.

Create the build-scripts/container/web, with this content:

#!/bin/bash

bundle check || bundle install

bundle exec rake db:setup && \
bundle exec rails s -p 3000 -b '0.0.0.0' -P /tmp/rails.pid

You can choose to exchange the rake db:setup to rake db:migrate or something like this.

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

ok, I think I have figured it out. I ran rake db:migrate --trace because of a comment above and got a huge error that started off with:

rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
ActiveRecord::NoDatabaseError: Unknown database 'recipe_library_development'Run `$ bin/rake db:create db:migrate` to create your database

So, based on that I ran: bin/rake db:create db:migrate

I reloaded my page and the error went away.

Still get Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development even after migration & deleting duplicate file

Looks like you are in a tangle.

I hope data is not important on your development env.

Run

rake db:drop db:create db:migrate

Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development, works localy tho

After searching the net for like 3 days for an answer I got one from a friend of mine.

He told me get rid of the big red error message "pending migrations"
I had to do

docker-compose exec app bash

and inside that do

rake db:migrate

and then

exit

Which I did and then my problems where gone. So it works now as it should. Hope that someone else can benefit from this too.

error Migrations are pending; run 'rake db:migrate RAILS_ENV=development' to resolve this issue

If you rollback a migration, the database schema is reverted to the previous migration.

However, if you leave the migration inside the migrations folder, Rails assumes the migration should be run and will not working until you migrate to the most recent schema.

If you want to rollback the schema you should discard the migration. Delete the file and Rails will not complain.



Related Topics



Leave a reply



Submit