This project is archived and is in readonly mode.

#2642 ✓invalid
Mathieu Jobin

db:migrate:reset should not drop all tables

Reported by Mathieu Jobin | May 13th, 2009 @ 08:08 PM | in 2.x

with the old migration system you could simply do

rake migrate VERSION=0 && rake migrate

wish would call all the down() methods and then restore everything.

now, with db:migrate:reset it kills everything. while I wish it would simply revert my migration and applies them again

thanks

Comments and changes to this ticket

  • Steve St. Martin

    Steve St. Martin April 16th, 2010 @ 01:23 AM

    • Assigned user set to “Ryan Bigg”

    Can you provide a bit more detail as to what your trying to accomplish? db:migrate:reset works as expected perhaps what your looking for is db:migrate:redo or db:migrate:rollback, not sure why it matters dropping all the tables if your starting over.

    can be marked as invalid or incomplete

  • Ryan Bigg

    Ryan Bigg April 16th, 2010 @ 01:23 AM

    • State changed from “new” to “incomplete”
  • Mathieu Jobin

    Mathieu Jobin April 16th, 2010 @ 04:08 AM

    db:migrate:reset is definitely useful as well.
    but I'd like something that would just revert all migration calling all the down() methods one by one from the last to the first.

  • Jeff Kreeftmeijer

    Jeff Kreeftmeijer April 16th, 2010 @ 09:46 AM

    If I understand correctly, you're trying to roll back every migration my calling down() (like Mathieu said) On 2.3.5, rake db:migrate VERSION=0 just seems to work:

    ~/rails$ rails -v
    Rails 2.3.5
    ~/rails$ rails migrate_reset
          ...
    ~/rails$ cd migrate_reset/
    ~/rails/migrate_reset$ script/generate model user name:string
          ...
    ~/rails/migrate_reset$ script/generate model book title:string
          ...
    ~/rails/migrate_reset$ rake db:migrate
    (in /Users/jeff/rails/migrate_reset)
    ==  CreateUsers: migrating ====================================================
    -- create_table(:users)
       -> 0.0015s
    ==  CreateUsers: migrated (0.0017s) ===========================================
    
    ==  CreateBooks: migrating ====================================================
    -- create_table(:books)
       -> 0.0012s
    ==  CreateBooks: migrated (0.0013s) ===========================================
    
    ~/rails/migrate_reset$ rake db:migrate VERSION=0
    (in /Users/jeff/rails/migrate_reset)
    ==  CreateBooks: reverting ====================================================
    -- drop_table(:books)
       -> 0.0026s
    ==  CreateBooks: reverted (0.0027s) ===========================================
    
    ==  CreateUsers: reverting ====================================================
    -- drop_table(:users)
       -> 0.0019s
    ==  CreateUsers: reverted (0.0021s) ===========================================
    
    ~/rails/migrate_reset$
    

    I've also tried this on edge. Same results. I think this one can be marked as invalid.

  • Ryan Bigg

    Ryan Bigg April 19th, 2010 @ 10:13 PM

    • State changed from “incomplete” to “invalid”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages