将 db/schema.rb 放到 .gitignore 列表中是个好主意吗?

编程入门 行业动态 更新时间:2024-10-14 02:21:49
本文介绍了将 db/schema.rb 放到 .gitignore 列表中是个好主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我在工作中的建议是将 db/schema.rb 放入 .gitignore 文件中,这样我们就没有(不时)合并问题.

so what I'm suggesting in my job, is to put db/schema.rb into .gitignore file, so we don't have (time to time) merging problems.

有些担心,如果发生可怕的事情(流星从天而降,正好在数据库服务器上,同时所有 db/migrete 文件都损坏了),我们可能会丢失架构,我们将不得不使用 rake db:purge(重用 schema.rb).我同意这是可能的,这是一个很好的论点,但这应该不是问题,因为每次我们执行 rake db:migrate 时都会生成 db/schema.rb.因此,即使我们不会在服务器上推送 schema.rb,我们也会在每次部署数据库更改时添加运行 db:migrate 并且 db:migrate rails 将在服务器端自动生成 schema.rb,并且schema.rb 在服务器上保持不变,直到我们执行另一个 db:migrate .

There are some concerns that if something terrible happen (meteor fall from the sky right on the DB server and simultaneously all the db/migrete files are corrupt) we could loose the schema, and we will have to use rake db:purge (to reuse the schema.rb). I agree that this is possible and it's a good argument, but it shouldn't be problem because db/schema.rb is generated each time we do rake db:migrate. So even if we won't push schema.rb on server, we are pushing migrations add running db:migrate each time we are deploying with DB changes and with that db:migrate rails will automatically generate schema.rb on server side, and that schema.rb sits on the server unchanged until we do another db:migrate .

那么您的意见是,我们应该还是不应该将 db/schema.rb 放入 git ignore 中?

so whats your opinion, should we or should we not put the db/schema.rb into git ignore ?

谢谢你

推荐答案

我总是建议将 schema.rb 保留在版本控制中,因为像 rake db:schema:load 这样的任务取决于它的存在.

I would always suggest to keep schema.rb in version contol, since tasks like rake db:schema:load depend on it being there.

关于冲突,您是在谈论架构版本冲突吗?使用此处显示的合并算法可以轻松缓解这些问题:tbagery/2010/10/24/reduce-your-rails-schema-conflicts.html

About the conflicts, are you talking about the schema version conflicts? These are easily mitigated using the merge algorithm showed here: tbaggery/2010/10/24/reduce-your-rails-schema-conflicts.html

其他冲突,例如列定义切换位置,可以通过小心提交到存储库的内容来轻松避免.

Other conflicts, like column definition switching locations can easily be avoided by being careful what you commit to the repository.

更多推荐

将 db/schema.rb 放到 .gitignore 列表中是个好主意吗?

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

发布评论

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

>www.elefans.com

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