How to delete migration files in Rails 3

前端 未结 11 1101
盖世英雄少女心
盖世英雄少女心 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:52

    This also works in Rails 5.

    If the migration was the most recent one you can remove the database column(s) that the migration added by doing:

    rake db:rollback
    

    then remove the migration file itself by running:

    rails d migration WhateverYourMigrationWasNamed.rb 
    

提交回复
热议问题