git项目的特定分支的不同数据库 [英] Different databases for specific branches of git project

查看:171
本文介绍了git项目的特定分支的不同数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个项目的几个分支共享大约一半的代码,并使用git checkout同时开发它们。现在,问题出现时,模型变得如此不同,以至于不再可能为其开发保留相同的数据库。我可以在config / databases.yml中为每个分支专门指定数据库名称,但它不被跟踪。另一个解决方案是使用分支名称跟踪某个外部文件,例如config / branch.txt,并在config / databases.yml中引用它:

  all:
doctrine:
class:sfDoctrineDatabase
param:
dsn:'pgsql:host = localhost; dbname =<?php echo file_get_contents(realpath (__DIR__。'/branch.txt'))?>'

无论如何,你如何解决这是什么?

解决方案通常用于管理分支中不同内容的相同文件(无需处理合并问题)是:






从分支到分支的脚本和模板文件始终是相同的(无合并问题)。
生成的 config / databases.yml 仍然是私人的,而不是版本。


We have several branches of one project that share about half of the code and develop them simultaneously with git checkout. Now, the problem came when the model became so different, that it is no longer possible to keep the same database for their development. I could have specified the database name in the config/databases.yml specifically for each branch, but it is not tracked. Another solution would be to track some external file with branch name, for example, config/branch.txt, and reference it in config/databases.yml:

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'pgsql:host=localhost;dbname=<?php echo file_get_contents (realpath(__DIR__ . '/branch.txt')) ?>'

Anyway, how do you tackle this?

解决方案

What is usually done for managing the same file with different content amongst branch (without having to deal with merge issue) is to:

  • use a merge driver (like keepmine) in order to always keep the local version of the file during a merge

  • or use a filter driver with:

    • a config/databases.yml.tpl versioned
    • a way to get back the right value depending on the environment (like the name of the current branch)
    • a 'smudge' script (versioned) which will combine, on checkout, the template and the right values in order to produce a complete config/databases.yml

The script and the template file are always the same from branch to branch (no merge issue).
The resulting config/databases.yml remains a private one, not versioned.

这篇关于git项目的特定分支的不同数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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