Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

db:migrate:reset should not drop all tables

#2642

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

Reported by Mathieu Jobin · May 13th, 2009 @ 08:08 PM

State: invalid
Milestone: 2.x
Assigned to: Ryan Bigg Ryan Bigg
Importance: none

Activity

  1. Steve St. Martin
    Steve St. Martin
    • 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

    April 16th, 2010 @ 01:23 AM

  2. Ryan Bigg
    Ryan Bigg
    • State changed from new to incomplete

    April 16th, 2010 @ 01:23 AM

  3. Mathieu Jobin
    Mathieu Jobin

    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.

    April 16th, 2010 @ 04:08 AM

  4. Jeff Kreeftmeijer
    Jeff Kreeftmeijer

    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.

    April 16th, 2010 @ 09:46 AM

  5. Ryan Bigg
    Ryan Bigg
    • State changed from incomplete to invalid

    April 19th, 2010 @ 10:13 PM