Rolling back a failed Rails migration

后端 未结 9 778
一向
一向 2020-12-07 17:03

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

9条回答
  •  天命终不由人
    2020-12-07 17:45

    Unfortunately, you must manually clean up failed migrations for MySQL. MySQL does not support transactional database definition changes.

    Rails 2.2 includes transactional migrations for PostgreSQL. Rails 2.3 includes transactional migrations for SQLite.

    This doesn't really help you for your problem right now, but if you have a choice of database on future projects, I recommend using one with support for transactional DDL because it makes migrations much more pleasant.

    Update - this is still true in 2017, on Rails 4.2.7 and MySQL 5.7, reported by Alejandro Babio in another answer here.

提交回复
热议问题