Kenny Ellis Kenny Ellis - 1 year ago 186
Ruby Question

Rails: How to delete a pending migration

I'm currently following the ruby on rails tutorial:

I am trying to save data into the database. However, when I run:

rails server
I get the following error:

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

I've looked at the other articles and when I run:

bin/rake db:migrate

I get a
rake aborted!

After running:

rake db:abort_if_pending_migrations....

I see that:

You have 1 pending migration:
20150805200129 CreateDatabases

SQLite3::SQLException: table "databases" already exists:

and it just tells me to run rake db:migrate to start again.

it seems that it already exists, is there a way to cancel the pending migration?

Answer Source

You migration may have failed midway (so it created the table, but didn't finish).

You are just using development environment, so it's okay to just drop database and rebuild it from scratch:

rake db:drop
rake db:create
rake db:migrate
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download