Different databases for specific git project branches

We have several branches of one project that have about half the code and develop them at the same time as git checking. Now the problem arose when the model became so different that it was no longer possible to save the same database for their development. I could specify the database name in config / databases.yml specifically for each branch, but it is not tracked. Another solution would be to track an external file with a 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 handle this?

+1
source share
1 answer

What is usually done to manage the same file with different content among the branches (without having to solve the merge problem):

  • use a merge file (e.g. keepmine ) to always keep the local version of the file during merge

  • or use a filter :

    • a config/databases.yml.tpl version
    • way to return the correct value depending on the environment (for example, the name of the current branch)
    • a ' smudge ' script (version), which will combine the template and the correct values ​​during verification to create the full config/databases.yml

smudge / clean

script and template file always match branch to branch (no merge problem).
The resulting config/databases.yml remains private, not the version.

+3
source

All Articles