Reputation: 11
After rake db:migrate:rollback STEP=1, rake db:migrate:reset, rake db:migrate:setup, rake db:migrate:up VERSION=XXXXXXXXX I get the following entry:
Status Migration ID Migration Name
------------------------------------------------------
up 0 *********NO FILE**********
up 20120209023430 Create tasks
How can I get rid of the orphaned entry? I have encountered this problem a few times after raking the db similar to above. Could somebody please explain what exactly causes this.
Thx in advance. Shahram
Upvotes: 1
Views: 2524
Reputation: 2918
I've just released this gem that can solve this issue for good.
The idea of that gem is simple. It keeps all migrated migrations inside tmp
folder so that Git ignores them. It's just only your local story. These files are needed to roll back the "unknown" migrations being in another branch. Now, whenever you have an inconsistent DB schema due to running migrations in some other branch just run rails db:migrate
inside the current branch and it will fix the issue automatically. The gem does all this magic automatically for you.
Upvotes: 0
Reputation: 1466
You could use rake db:migrate:reset db:seed
. It's a little less verbose and will completely wipe your database, re-run all migrations, and then seed your database from the db/seeds.rb
file.
Upvotes: 16