How to delete migration files in Rails 3

前端 未结 11 1089
盖世英雄少女心
盖世英雄少女心 2020-12-07 07:54

I would like to remove/delete a migration file. How would I go about doing that? I know there are similar questions on here but as an update, is there a better way than doin

11条回答
  •  生来不讨喜
    2020-12-07 08:33

    I usually:

    1. Perform a rake db:migrate VERSION=XXX on all environments, to the version before the one I want to delete.
    2. Delete the migration file manually.
    3. If there are pending migrations (i.e., the migration I removed was not the last one), I just perform a new rake db:migrate again.

    If your application is already on production or staging, it's safer to just write another migration that destroys your table or columns.

    Another great reference for migrations is: http://guides.rubyonrails.org/migrations.html

提交回复
热议问题