问题描述
经过一些研究,我们选择在下一个项目中与 Drupal 合作,我们是一个分布式团队.
after some research, we opted for working with Drupal on our next project and we are a distributed team.
既然 Drupal 将(基于我们目前所见)它的所有内容存储在数据库中,作为一个分布式团队,我们如何在这个项目上协同工作?我们应该采取哪些最佳实践?
Since Drupal stores (based on what we saw until now) all it's content on a database, how can we, as a distributed team work together on this project? What are the best practices we should take?
我们考虑过使用共享数据库服务器来执行此任务,但这只会破坏我们运行该项目所需的性能.对此有什么建议吗?
We thought about using a shared database server for this task, but it whould simply destroy the performance we should need to get this project going. Any suggestions about that?
推荐答案
Jeremy 的回答 (+1) 已经很全面了.以下是一些其他更实用的建议,没有特定的顺序.
Jeremy's answer (+1) is already quite comprehensive. Some additional more practical-oriented advice follows in no particular order.
免责声明:这是对我有用的东西.其他人可能有其他建议,甚至不同意.如果是这种情况,我会非常高兴听到反馈和替代/更好的建议!
Disclaimer: this is stuff that works for me. Others might have other suggestion or even disagree. If this is the case I would be superhappy to hear feedback and alternate/better proposals!
强调每个团队成员都应该通过更新代码和数据库来开始他/她的会话.您可以使用
ssh 的组合轻松编写所有这些脚本code> 和
rsync
命令.我有时会创建一个脚本 (update-project.sh
) 来更新存储库中的代码,然后立即从主服务器下载并导入最新的数据库.
Make a point that every team member should start his/her session by updating the code AND database. You can easily script all of that with a combination of
ssh
andrsync
commands. I at times create a single script (update-project.sh
) that updates the code from the repository and download and import the latest DB from the master server at once.
每次更新代码时都不要忘记调用 http://example.com/update.php
. 在临时站点上运行此命令,每次提交后,以及每次更新/拉取/签出后在您的本地机器上.
Never forget to call http://example.com/update.php
every time you update the code. Run this command on your staging site, after every commit, and on your local machine after every update/pull/checkout.
通过 SQL 查询对数据库进行任何更改,而不是使用 GUI. 这样您只需将该查询包装到 hook_update_N()
在 yourmodule.install 文件中的实现,以及你是安全的(如果你遵守第 2 点!)[一些 gui 工具输出等效的......这也很方便!].
Do any change to the DB via SQL query, rather than with a GUI. That way you will simply have to wrap that query into an hook_update_N()
implementation in your yourmodule.install file, and you are safe and sound (if you abide to point #2!) [some gui tool output the equivalent... that's handy too!].
尽可能在hook_update_N()
也会更改模块设置. 这并非总是可能的.如果不可能:请参阅第 7 点和第 8 点.
Whenever possible, include in hook_update_N()
also changes to module settings. This is not possible all the times. When not possible: see point #7 and #8.
创建或修改视图时,完成后将其导出到文件. 与第 3 点相同的原则,但适用于视图.顺便说一句,这种方法还具有提供回滚机制的好处,以防您后来意识到自己犯了错误.
When creating or modifying a view, export it to a file when finished. Same principle that point #3 but applied to views. This approach has incidentally also the benefit of providing a rollback mechanism in case you later realise you made a mistake.
使用主存储库.不要使用过多的分布式版本控制系统.始终从同一个中央存储库中拉取和推送您的代码.
Use a master repository. Don't go for a too much distributed versioning system. Pull and push your code always from the same central repo.
始终在提交中包含注释.特别是如果某些代码更改更改了某些功能/API/通用逻辑,请务必在提交消息中包含警告.如果需要,可以将详细信息放在 changelog.txt 文件中.
Always include a comment in your commit. Especially if some code change change some functionality / API / common logic, make a point to include a warning in your commit message. Detailed info can be put in a changelog.txt file, if needed.
在提交时,立即在主数据库上复制您尚未设法包含在 hook_update_N()
实现中的任何手工制作的数据库更改.如果您的团队成员按照 #1 中的描述开始他们的会议,这是必须的.
When committing, immediately reproduce on the master DB any hand-made DB changes that you haven't managed to include in your hook_update_N()
implementation. This is a must if your team members start their sessions like described in #1.
选择版本控制下的内容.例如:排除 sites/default/settings.php
但评估什么(如果有的话)需要在 sites/default/files
中进行版本控制(开发需要图片吗?和附件吗?).
Be selective in what you put under versioning. For example: exclude the sites/default/settings.php
but evaluate what (if anything at all) need to be versioned from in sites/default/files
(are images needed for development? and attachments?).
有一些有用的贡献模块可以提供帮助.比如 import/export,它允许您在存储库中管理您的 CCK 和视图或 节点导出,它允许您导出节点,然后将它们导入另一个 drupal 安装中.
There are some useful contributed modules that can help. Like import/export, which allows you to manage in a repository your CCK and Views or node export that allows you to export nodes and then import them back in another drupal installation.
广泛使用 simpletest 模块.这是一个好的想法,但是当团队合作时,这是一个好的想法:这样您就可以确保您的更改不会破坏其他人的工作.
Use the simpletest module extensively. That is a good idea anyhow, but when working in team is a great idea: that way you will be sure your changes haven't broken anybody else's work.
玩得开心!我喜欢团队合作,我相信每个人都应该尝试这样做.它更有趣,更多的学习,最重要的是......更好的代码!:)
Have fun! I love to work in team and I believe one should try to do that everytime he/she can. It's more fun, more learning and above all... better code! :)
加分点(不特指团队发展):
Bonus point (does not refer to team development specifically):
- 尽量不要使用临时服务器来插入真正的内容.理想情况下,您应该仅在代码以某种方式冻结或使用导入路由/模块时才开始创建内容:drupal 会在表中大量散布信息, 并且钩子系统很难跟踪哪些模块在何处存储了哪些信息:如果您在具有真实数据的数据库上进行开发,您将不可避免地在某些时候破坏某些表,并且您可能会在前一天意识到投入生产.:(
- Try not to use your staging server for real content insertion. Ideally you should start creating content only when the code is somehow freezed or use an import routing/module: drupal scatters information across tables a lot, and the system of hooks makes very difficult to track which modules have stored what information where: if you develop on a DB with real data, you will inevitably end up breaking some tables at some point, and you might realise that only the day before going into production. :(
这篇关于对于将在 Drupal 项目上工作的小型分布式团队来说,最佳实践是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!