0
votes

Im a bit confused about migrations and rollbacks in Rails 4.0.x.

I want to view my site before and after a migration change by using rake db:migrate and rake db:rollback.

However when I try to view the site after the rollback, I get an ActiveRecord error for a PendingMigrationError.

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

It seems like I am not allowed to see my site after I have done a rollback. Is that how it works?

I had assumed that using rollback allowed you to move your app back to the previous state and keep using it there. The Active Record Migrations guide doesn't seem to cover this situation, http://guides.rubyonrails.org/migrations.html

2

2 Answers

3
votes

Even though you've rolled back the database, the filesystem still has a migration under db/migrate that Rails knows has not been run. You either need to migrate (as mentioned by @user3865871 above, or you need to remove the migration file from the filesystem.

-2
votes

just run

rake db:migrate

before you run your server.

That should be it.

Thanks.