-
Hi, We would like to find a friction-less way to manage a separate database per git branch. Eg imagine the master branch, accompanied by a master DB and sqitch config and plan to set up the master DB. Now I start working on a feature X and start a new GIT feature branch X. I don't want to get in the way of my fellow developers, therefore I also create a new DB X. When I'm done implementing X, I want to merge back into master and delete the X DB. Now how do I best reconfigure sqitch in the X branch to use the new database X? If I add a target, then merging the changes back into master will have this left-over X target of the (now defunct) X branch, right? If I change the original target to point to the X DB, then merging into master will override the master target. I somehow want to temporarily, during the lifetime of a branch, override a target's database URI or (alternatively) create a temporary target that doesn't get merged back. (I hope this makes semse:) Any thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Most engines support environment variables and defaults that specify database connection information. Postgres, for example, will fall back on your local username as the database name and username. So if you set a target like this: sqitch add target local-dev db:pg:localhost/ Then for a user named sqitch deploy local-dev Or set export SQITCH_TARGET=local-dev
sqitch deploy # uses local-dev Of course, if you're setting environment variables, you can just do that generally, esp if youre engine doesn't natively support the flexibility you require. For example, you could use a tool like direnv and commit an
Then every time you check out a new branch, as long as you've told direnv to trust the file, it will automatically reset the environment variable with the branch name as part of the database name. HTH! |
Beta Was this translation helpful? Give feedback.
Most engines support environment variables and defaults that specify database connection information. Postgres, for example, will fall back on your local username as the database name and username. So if you set a target like this:
Then for a user named
bob
it would connect todb:pg:localhost/bob
and for a user namedsue
it would connect todb:pg:localhost/sue
. All you have to do is remember to use it each timeOr set
$SQITCH_TARGET
to that target:Of course, if you're setting environment variables, you can just do that generally, esp if youre engine doesn't n…