Rolling back a failed Rails migration

后端 未结 9 771
一向
一向 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 18:01

    I agree that you should use PostgreSQL when possible. However, when you are stuck with MySQL, you can avoid most of these problems by trying your migration on your test database first:

    rake db:migrate RAILS_ENV=test
    

    You can revert to the previous state and try again with

    rake db:schema:load RAILS_ENV=test
    

提交回复
热议问题