Reputation: 13943
How can I delete / rollback all the migrations that have been run without having to drop and setup the database
rake db:rollback
goes back just one version. How can I get it to go all the way ?
Upvotes: 0
Views: 1015
Reputation: 2519
One way is :
rake db:rollback STEP=10000000
Which pretty much means hacking your way back so many steps that the migration always goes to step 0. Another way is:
rake db:migrate VERSION=0
More references here.
Upvotes: 4
Reputation: 5197
To rollback all the migrations use bin/rake:db reset
.
Pay attention, if a migration can't be rolledback, rake db:reset may fails.
Upvotes: 0
Reputation: 4561
You can run $ rake db:migrate:status
to see all of your migrations and whether they're in the up or down state. Go to the very first migration in that list and run:
rake db:rollback VERSION=version_id_shown_by_migrate_status_list_you_just_did
Note that if you undo all migrations, all data will be lost when the columns or tables are dropped. You can then reload the migrations by doing a normal rake db:migrate
Upvotes: 0