如何在Rails 3中删除迁移文件 [英] How to delete migration files in Rails 3

查看:115
本文介绍了如何在Rails 3中删除迁移文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除/删除迁移文件。我将如何去做呢?我知道这里有类似的问题,但作为更新,有没有更好的方法比做脚本/销毁?

另外,我应该做一个 db:reset db:drop 如果我删除/删除迁移?执行一个 rake db:migrate VERSION = XXX 在所有环境中,到我要删除的版本之前。

  • 手动删除迁移文件。

  • 如果有未决的迁移(即,我删除的迁移不是最后一个),我只是再次执行新的 rake db:migrate 。 $ b

    如果您的应用程序已经在生产或分期阶段,那么只需编写另一个销毁您的表或列的迁移就可以了。



    迁移的另一个重要参考是: http://guides.rubyonrails.org/migrations。 HTML


    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 doing script/destroy?

    Also, should I do a db:reset or db:drop if I remove/delete a migration?

    解决方案

    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

    这篇关于如何在Rails 3中删除迁移文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆