Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6975439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:22:05+00:00 2026-05-27T17:22:05+00:00

I’m getting some unexpected behaviour with rake db:migrate and rake db:rollback . Am hoping

  • 0

I’m getting some unexpected behaviour with rake db:migrate and rake db:rollback. Am hoping someone might be able to shed some light for me.

I made a mess of my migrations by adding a conflicting one in, and I’m trying to migrate back to 0 so that I can migrate up again and continue knowing that everything is going to work OK.

I was running rake db:migrate version=0 and just getting dumped back at the command line, with no migrations reported and no effects on my database. I do have a Rakefile, and my database.yml file is set up with correct login credentials.

Playing around, I found I was able to go rake db:rollback step=1 with no problems: the appropriate actions would happen as per the migrations. However, rake db:rollback step=2 (or step=3 or step=5 — anything other than 1) would only ever do one migration at a time.

Used mysql in the terminal to drop the database entirely. Recreated it, then went rake db:migrate. All the tables got built as they should have. I assumed whatever was broken was fixed.

So I went rake db:migrate version=0…. and again nothing happened. Tables still exist in the database where it should’ve gone back to being empty.

Does anyone have any ideas? Have pretty much scratched a hole in my scalp here at this point.

After manually dropping the database and running my migrations, rake db:migrate version=0 --dry-run --trace gives me the response:

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute (dry run) environment
** Execute (dry run) db:migrate

My migrations at this point are all just replications of the RailsTutorial.org ones, which is what I’ve been working off until now as a learning exercise; they do all have self.down methods and they all work when I step it back one at a time.

The only other thing that might be relevant is that I completed that tutorial on a different computer (my PC); I pushed it up to github and cloned it onto my Mac in order to use the tutorial as a starting point for my own work. The app does seem to run okay in my browser on the Mac (same as on the PC), although I’ve been following a myriad of tutorials to get the Rails environment (RVM) set up on the Mac for the first time and I’ve installed different gems to do so. Could my problem possibly stem from here?

Thanks for any advice!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:22:06+00:00Added an answer on May 27, 2026 at 5:22 pm

    This article might help you.

    Basically, you can tweak db:rollback task.

    namespace :db do
      desc 'Rolls the schema back to the previous version. Specify the number of steps with STEP=n'
      task :rollback => :environment do
        step = ENV['STEP'] ? ENV['STEP'].to_i : 1
        version = ActiveRecord::Migrator.current_version - step
        ActiveRecord::Migrator.migrate('db/migrate/', version)
      end
    end
    

    So now you can do this:

    rake db:rollback STEP=3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.