将 db/schema.rb 放到 .gitignore 列表中是个好主意吗? [英] Is it a good idea to put db/schema.rb to .gitignore list ??

查看:13
本文介绍了将 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.

关于冲突,您是在谈论架构版本冲突吗?使用此处显示的合并算法可以轻松缓解这些问题:http://tbagery.com/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: http://tbaggery.com/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 列表中是个好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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