gitignore列表是个好主意吗

gitignore列表是个好主意吗

本文介绍了将db / schema.rb放入.gitignore列表是个好主意吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



那么你的意见是否应该或不应该把db / schema.rb放到git中忽略?





关于冲突,你在谈论模式版本冲突吗?使用这里显示的合并算法可以轻松缓解这些问题:



其他冲突,如列定义切换位置可以很容易地通过小心你提交到存储库的内容。

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.

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 .

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

thank you

解决方案

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

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列表是个好主意吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 04:54