ruby-on-rails - 清除旧的 Rails 迁移文件是个好主意吗?

标签 ruby-on-rails ruby activerecord migration

我已经运行一个大型 Rails 应用程序 2 年多了,一天天过去,我的 ActiveRecord 迁移文件夹已经增长到超过 150 个文件。

有一些非常旧的模型,在应用程序中不再可用,但仍会在迁移中引用。我想删除它们。

你怎么看?您通常会从代码库中清除旧的迁移吗?

最佳答案

The Rails 4 Way第 177 页: 塞巴斯蒂安说……

A little-known fact is that you can remove old migration files (while still keeping newer ones) to keep the db/migrate folder to a manageable size. You can move the older migrations to a db/archived_migrations folder or something like that. Once you do trim the size of your migrations folder, use the rake db:reset task to (re-)create your database from db/schema.rb and load the seeds into your current environment.

关于ruby-on-rails - 清除旧的 Rails 迁移文件是个好主意吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4248682/

相关文章:

ruby-on-rails - 如何重置 bundle 程序路径

ruby-on-rails - RubyMine 终端使用了错误的 RVM,并且在 Rails 控制台中没有历史记录

ruby-on-rails - 如何将 `DateTime` 转换为柏林相应的日期和时间?

activerecord - 是什么导致 ActiveRecord 在 fork 后中断 Postgres 连接?

ruby-on-rails - :dependent => :delete on belongs_to doesn't delete owner object

ruby-on-rails - Rails ActiveRecord 返回相关表中存在 id 的记录

ruby-on-rails - 在 Sinatra 中使用 Rack::Session::Pool

ruby - 如果在数组中找不到项目,则使用默认值

ruby - 仅在存在时修改 Ruby 散列中的值

ruby-on-rails - 如何在 Ruby 中查询方法的结果 (rails)