mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +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:
parent
c974cb3de8
commit
570feee199
4 changed files with 34 additions and 6 deletions
|
@ -719,6 +719,13 @@ return array(
|
||||||
// fits within configured limits.
|
// fits within configured limits.
|
||||||
'storage.engine-selector' => 'PhabricatorDefaultFileStorageEngineSelector',
|
'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 ---------------------------------------------------------------- //
|
// -- Search ---------------------------------------------------------------- //
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ $conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider');
|
||||||
$default_user = $conf->getUser();
|
$default_user = $conf->getUser();
|
||||||
$default_password = $conf->getPassword();
|
$default_password = $conf->getPassword();
|
||||||
$default_host = $conf->getHost();
|
$default_host = $conf->getHost();
|
||||||
$default_namespace = 'phabricator';
|
$default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$args->parsePartial(
|
$args->parsePartial(
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
abstract class PhabricatorLiskDAO extends LiskDAO {
|
abstract class PhabricatorLiskDAO extends LiskDAO {
|
||||||
|
|
||||||
private $edges = array();
|
private $edges = array();
|
||||||
private static $namespace = 'phabricator';
|
private static $namespaceStack = array();
|
||||||
|
|
||||||
|
|
||||||
/* -( Managing Edges )----------------------------------------------------- */
|
/* -( Managing Edges )----------------------------------------------------- */
|
||||||
|
@ -65,18 +65,39 @@ abstract class PhabricatorLiskDAO extends LiskDAO {
|
||||||
/**
|
/**
|
||||||
* @task config
|
* @task config
|
||||||
*/
|
*/
|
||||||
public static function setApplicationNamespace($namespace) {
|
public static function pushStorageNamespace($namespace) {
|
||||||
self::$namespace = $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
|
* @task config
|
||||||
*/
|
*/
|
||||||
public function establishLiveConnection($mode) {
|
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(
|
$conf = PhabricatorEnv::newObjectFromConfig(
|
||||||
'mysql.configuration-provider',
|
'mysql.configuration-provider',
|
||||||
array($this, $mode, self::$namespace));
|
array($this, $mode, $namespace));
|
||||||
|
|
||||||
return PhabricatorEnv::newObjectFromConfig(
|
return PhabricatorEnv::newObjectFromConfig(
|
||||||
'mysql.implementation',
|
'mysql.implementation',
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class PhabricatorStorageManagementAPI {
|
||||||
|
|
||||||
public function setNamespace($namespace) {
|
public function setNamespace($namespace) {
|
||||||
$this->namespace = $namespace;
|
$this->namespace = $namespace;
|
||||||
PhabricatorLiskDAO::setApplicationNamespace($namespace);
|
PhabricatorLiskDAO::pushStorageNamespace($namespace);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue