我应该扁平化 Rails 迁移吗?

发布于 2024-08-14 19:17:22 字数 81 浏览 4 评论 0原文

可以将 db/migrate/* 替换为 db/schema.rb 的内容,这样您就只有一个迁移步骤。

你们有人这样做过吗?为什么?

It's possible to replace db/migrate/* with the contents of db/schema.rb, so that you only have one migration step.

Do any of you ever do this? Why?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

丿*梦醉红颜 2024-08-21 19:17:22

你为什么要这样做?如果您不想运行所有迁移,则可以运行 rake db:schema:load 。迁移不仅用于初始化新数据库,还用于将其迁移到另一个版本。

Why would you want to do this? You could just run rake db:schema:load if you don't want to run all migrations. Migrations are used not (only) to initialize a new database, but to migrate it to another version.

爱冒险 2024-08-21 19:17:22

此外,一些大型 Rub​​y on Rails 工具包(比如我现在忘记的那个可以让您在 Rails 应用程序中设置电子商务网站的软件包)使它们的迁移变得扁平化。

我还知道有大量迁移的项目每隔一段时间就执行一次此操作,以减少运行 rake db:migrate start to finish 所需的时间(例如,在持续集成服务器上)

Also, some big Ruby on Rails kit packages (like that one that's slipping my mind now that lets you set up an ecommerce site in your Rails app), flatten their migrations.

I've also known of projects with a ton of migrations to do this every once in a while to reduce the amount of time it takes to run rake db:migrate start to finish (say, on the continuous integration server)

清晰传感 2024-08-21 19:17:22

您可以执行 rake db:schema:load 一步导入整个架构。建议这样做,而不是运行大量迁移。

You can do rake db:schema:load to import the entire schema in one step. This is recommended, as opposed to running a ton of migrations.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文