rails db:migrate vs rake db:migrate

编程入门 行业动态 更新时间:2024-10-13 02:15:48
本文介绍了rails db:migrate vs rake db:migrate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是 Rails 的新手.我注意到在 rails 5 中生成数据迁移时,有些人使用 rails db:migrate 而不是 rake db:migrate.有人可以解释数据库迁移中 rails 与 rake 命令之间的区别吗?这是否意味着 rake 命令在 rails 5 中已过时?

I'm new to rails. I noticed when generating data migration in rails 5, some people use rails db:migrate over rake db:migrate. Can someone explain the difference between the rails vs rake command in database migration? Does it mean rake command is obsolete in rails 5?

非常感谢

推荐答案

Rails 核心团队决定通过启用 rails 命令来支持 rake 所做的一切来保持一致性.

Rails core team decided to have consistency by enabling rails command to support everything that rake does.

例如在 Rails 5 命令中,如 db:migrate、db:setup、db:test 等,它们是 rake 命令的一部分Rails 命令现在支持 Rails 4.但是,您仍然可以选择使用 rake 来运行这些命令,类似于它们在 Rails 4 中的运行方式.这是因为 Rails 社区引入了 Rake 代理,而不是将命令选项从 rake 完全移动到 rails.

For example in Rails 5 commands like db:migrate, db:setup, db:test etc which are part of rake command in Rails 4 are now being supported by rails command. However you can still choose to use rake to run those commands similar to how they were run in Rails 4. This is because Rails community has introduced Rake Proxy instead of completely moving the command options from rake to rails.

内部发生的事情是,当 rails db:migrate 命令被执行时,Rails 会检查 db:migrate 是否是 Rails 原生支持的东西.在这种情况下,db:migrate 不受 rails 的原生支持,因此 Rails 通过 Rake 代理将执行委托给 Rake.

What happens internally is that when rails db:migrate command is executed, Rails checks if db:migrate is something that rails natively supports or not. In this case db:migrate is not natively supported by rails, so Rails delegates the execution to Rake via Rake Proxy.

如果您想查看 Rails 5 中 rails 支持的所有命令,那么您可以通过执行 rails --help 获得一长串选项.

If you want to see all the commands that is supported by rails in Rails 5 then you can get a long list of options by executing rails --help.

更多推荐

rails db:migrate vs rake db:migrate

本文发布于:2023-10-18 15:08:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1504586.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:db   rails   rake   migrate

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!