Created
October 2, 2012 15:36
-
-
Save ncherro/3820222 to your computer and use it in GitHub Desktop.
Drupal branch-specific database settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// full path to project root (you'll need to edit this) | |
$root = dirname(dirname(dirname(__DIR__))); | |
// project name here (full db name will be my_project_[current git branch]) | |
$project_name = 'my_project'; | |
// base connection info | |
$base_conn = array( | |
'driver' => 'mysql', | |
'username' => 'USERNAME', | |
'password' => 'PASSWORD', | |
'host' => 'localhost', | |
'prefix' => '', | |
); | |
// set the database name based on which git branch we're in | |
$branch = file($root . '/.git/HEAD'); | |
$branch = reset($branch); | |
$branch = explode('/', $branch); | |
$branch = trim($branch[2]); | |
$databases['default']['default'] = $base_conn + array( | |
'database' => $project_name . '_' . $branch, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment