3

I just want to roll one version back, But I don't know the current VERSION, Is there a command to check it?

3
  • sorry dude, I was too excited to try each solution out, and forget came back to accept answer Commented Dec 10, 2010 at 15:35
  • no problem ^^ I was just wondering if I had to add anything to my answer Commented Dec 10, 2010 at 17:15
  • how to add @yozloy in the front of your comment, it's a quote function or what? Commented Dec 11, 2010 at 4:45

3 Answers 3

8

First, it's worth taking the time to read the Rails Guide regarding migrations. Then regarding your specific question:

... to roll back one version:

rake db:rollback STEP=1

... to see the current version:

rake db:version
Sign up to request clarification or add additional context in comments.

Comments

2

VERSION essentially is the name of a specific migration and not a point in time. You need to roll back multiple such “versions” to get back in time. These versions have the same names as the file names in db/migrate (without extension). This can be used to roll back a specific migration without undoing migrations done later.

Use the STEP parameter to go back in time a specified amount of migration steps.

Comments

2

Migrations are timestamped. It is safe to assume that the latest timestamp is the current migration in most instances.

http://guides.rubyonrails.org/migrations.html#rolling-back

1 Comment

Great link - always needed rake db:migrate:redo STEP=3

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.