How do you roll back a failed rails migration? I would expect that rake db:rollback
would undo the failed migration, but no, it rolls back the previous migratio
Alejandro Babio's answer above provides the best current answer.
One additional detail I want to add:
When the myfailedmigration
migration fails, it is not considered as applied, and this can be verified by running rake db:migrate:status
, which would show output similar to the following:
$ rake db:migrate:status
database: sample_app_dev
Status Migration ID Migration Name
--------------------------------------------------
up 20130206203115 Create users
...
...
down 20150501173156 Test migration
The residual effect of add_column :assets, :test, :integer
being executed on the failed migration will have to be reversed at the database level with a alter table assets drop column test;
query.