1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 08:12:40 +01:00

Make default database namespace configurable

Summary: Allow the default namespace to be set in configuration, so you can juggle multiple copies of sandbox test data or whatever.

Test Plan: Changed default namespace, verified web UI and "storage" script respect it.

Reviewers: btrahan, vrana, jungejason

Reviewed By: vrana

CC: aran

Maniphest Tasks: T345

Differential Revision: https://secure.phabricator.com/D2341
This commit is contained in:
epriestley 2012-04-30 11:56:58 -07:00
parent c974cb3de8
commit 570feee199
4 changed files with 34 additions and 6 deletions

View file

@ -719,6 +719,13 @@ return array(
// fits within configured limits.
'storage.engine-selector' => 'PhabricatorDefaultFileStorageEngineSelector',
// Phabricator puts databases in a namespace, which defualts to "phabricator"
// -- for instance, the Differential database is named
// "phabricator_differential" by default. You can change this namespace if you
// want. Normally, you should not do this unless you are developing
// Phabricator and using namespaces to separate multiple sandbox datasets.
'storage.default-namespace' => 'phabricator',
// -- Search ---------------------------------------------------------------- //

View file

@ -40,7 +40,7 @@ $conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider');
$default_user = $conf->getUser();
$default_password = $conf->getPassword();
$default_host = $conf->getHost();
$default_namespace = 'phabricator';
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
try {
$args->parsePartial(

View file

@ -23,7 +23,7 @@
abstract class PhabricatorLiskDAO extends LiskDAO {
private $edges = array();
private static $namespace = 'phabricator';
private static $namespaceStack = array();
/* -( Managing Edges )----------------------------------------------------- */
@ -65,18 +65,39 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
/**
* @task config
*/
public static function setApplicationNamespace($namespace) {
self::$namespace = $namespace;
public static function pushStorageNamespace($namespace) {
self::$namespaceStack[] = $namespace;
}
/**
* @task config
*/
public static function popStorageNamespace($namespace) {
array_pop(self::$namespaceStack);
}
/**
* @task config
*/
public static function getDefaultStorageNamespace() {
return PhabricatorEnv::getEnvConfig('storage.default-namespace');
}
/**
* @task config
*/
public function establishLiveConnection($mode) {
$namespace = end(self::$namespaceStack);
if (!strlen($namespace)) {
$namespace = self::getDefaultStorageNamespace();
}
if (!strlen($namespace)) {
throw new Exception("No storage namespace configured!");
}
$conf = PhabricatorEnv::newObjectFromConfig(
'mysql.configuration-provider',
array($this, $mode, self::$namespace));
array($this, $mode, $namespace));
return PhabricatorEnv::newObjectFromConfig(
'mysql.implementation',

View file

@ -25,7 +25,7 @@ final class PhabricatorStorageManagementAPI {
public function setNamespace($namespace) {
$this->namespace = $namespace;
PhabricatorLiskDAO::setApplicationNamespace($namespace);
PhabricatorLiskDAO::pushStorageNamespace($namespace);
return $this;
}