我们有很多数据库迁移文件-我们应该保留它们吗? [英] We have lots of database migration files - should we keep them?

查看:66
本文介绍了我们有很多数据库迁移文件-我们应该保留它们吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们大约有100个数据库迁移文件。他们中的许多人进行不可逆的架构更改。还有后来的迁移会更改或删除在先前的迁移中创建的表。

We have around 100 database migration files. Many of them make schema changes which are irreversible. There are also later migrations which change or remove tables which were created in earlier migrations.

我们直接从schema.rb文件创建新数据库,因此我们想知道是否

We are creating new databases straight from the schema.rb file, so we were wondering if there is any reason to keep the full set of migrations?

我们将基于现有的schema.rb创建一个新的迁移。

We would create a new migration which is based on our existing schema.rb.

推荐答案

是的,您提出的建议被认为是最佳做法。

Yes, what you're proposing is considered a best practice.

我已经用旧的应用程序完成了几次。您需要将迁移备份到某个地方,直到您满意为止,当然,这是应用程序维护的重要组成部分-如果您有很多旧迁移,则执行<$ c可能要花很长时间。 $ c> db:reset 或运行新的开发环境。

I've done this with my old apps several times. You'll want to back your migrations up somewhere until you're satisfied all is well, of course, this is an important part of application maintenance - if you have a lot of old migrations, it can take forever to do a db:reset or to get a new development environment running.

这篇关于我们有很多数据库迁移文件-我们应该保留它们吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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