1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 13:00:56 +01:00

Mark dead databases as "dead" and don't dump, probe, or list them

Summary:
When we delete a database, we still need to create it in the patch sequence so that installs can upgrade correctly. However, we shouldn't try to dump, probe, or list it. Mark deleted databases (of which there is only one) as "dead" and don't dump them.

A specific problem this fixes is `bin/storage dump` failing when trying to dump `phabricator_timeline`, which no longer exists.

Test Plan: Ran `bin/storage dump`, `list`, `probe`.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6496
This commit is contained in:
epriestley 2013-07-19 11:07:29 -07:00
parent 74ded4c1c5
commit 83c29da594
7 changed files with 16 additions and 4 deletions

View file

@ -58,13 +58,16 @@ final class PhabricatorStorageManagementAPI {
return $this->namespace.'_'.$fragment;
}
public function getDatabaseList(array $patches) {
public function getDatabaseList(array $patches, $only_living = false) {
assert_instances_of($patches, 'PhabricatorStoragePatch');
$list = array();
foreach ($patches as $patch) {
if ($patch->getType() == 'db') {
if ($only_living && $patch->isDead()) {
continue;
}
$list[] = $this->getDatabaseName($patch->getName());
}
}

View file

@ -8,6 +8,7 @@ final class PhabricatorStoragePatch {
private $type;
private $after;
private $legacy;
private $dead;
public function __construct(array $dict) {
$this->key = $dict['key'];
@ -16,6 +17,7 @@ final class PhabricatorStoragePatch {
$this->legacy = $dict['legacy'];
$this->name = $dict['name'];
$this->after = $dict['after'];
$this->dead = $dict['dead'];
}
public function getLegacy() {
@ -42,4 +44,8 @@ final class PhabricatorStoragePatch {
return $this->key;
}
public function isDead() {
return $this->dead;
}
}

View file

@ -14,7 +14,7 @@ final class PhabricatorStorageManagementDatabasesWorkflow
$api = $this->getAPI();
$patches = $this->getPatches();
$databases = $api->getDatabaseList($patches);
$databases = $api->getDatabaseList($patches, $only_living = true);
echo implode("\n", $databases)."\n";
return 0;

View file

@ -25,7 +25,7 @@ final class PhabricatorStorageManagementDumpWorkflow
return 1;
}
$databases = $api->getDatabaseList($patches);
$databases = $api->getDatabaseList($patches, $only_living = true);
list($host, $port) = $this->getBareHostAndPort($api->getHost());

View file

@ -18,7 +18,7 @@ final class PhabricatorStorageManagementProbeWorkflow
$api = $this->getAPI();
$patches = $this->getPatches();
$databases = $api->getDatabaseList($patches);
$databases = $api->getDatabaseList($patches, $only_living = true);
$conn_r = $api->getConn(null);

View file

@ -126,6 +126,7 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'db.timeline' => array(
'type' => 'db',
'name' => 'timeline',
'dead' => true,
),
'db.user' => array(
'type' => 'db',

View file

@ -40,6 +40,7 @@ abstract class PhabricatorSQLPatchList {
'name' => true,
'after' => true,
'legacy' => true,
'dead' => true,
);
foreach ($patch as $pkey => $pval) {
@ -73,6 +74,7 @@ abstract class PhabricatorSQLPatchList {
$patch['key'] = $key;
$patch['fullKey'] = $full_key;
$patch['dead'] = (bool)idx($patch, 'dead', false);
if (isset($patch['legacy'])) {
if ($namespace != 'phabricator') {