Different databases for specific branches of git project

六眼飞鱼酱① 提交于 2019-12-20 04:51:05

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7285978/different-databases-for-specific-branches-of-git-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!