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

Add setup check for missing SQL patches

Test Plan: Saw the warning, upgraded storage, didn't see it.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5618
This commit is contained in:
Jakub Vrana 2013-04-09 21:37:20 -07:00
parent 677f4ae83f
commit c48bb5494a

View file

@ -15,16 +15,16 @@ final class PhabricatorSetupCheckDatabase extends PhabricatorSetupCheck {
ini_set('mysql.connect_timeout', 2);
$config = array(
'user' => $conn_user,
'pass' => $conn_pass,
'host' => $conn_host,
'database' => null,
);
$conn_raw = PhabricatorEnv::newObjectFromConfig(
'mysql.implementation',
array(
array(
'user' => $conn_user,
'pass' => $conn_pass,
'host' => $conn_host,
'database' => null,
),
));
array($config));
try {
queryfx($conn_raw, 'SELECT 1');
@ -80,6 +80,29 @@ final class PhabricatorSetupCheckDatabase extends PhabricatorSetupCheck {
->setMessage($message)
->setIsFatal(true)
->addCommand(hsprintf('<tt>phabricator/ $</tt> ./bin/storage upgrade'));
} else {
$config['database'] = $namespace.'_meta_data';
$conn_meta = PhabricatorEnv::newObjectFromConfig(
'mysql.implementation',
array($config));
$applied = queryfx_all($conn_meta, 'SELECT patch FROM patch_status');
$applied = ipull($applied, 'patch', 'patch');
$all = PhabricatorSQLPatchList::buildAllPatches();
$diff = array_diff_key($all, $applied);
if ($diff) {
$this->newIssue('storage.patch')
->setName(pht('Upgrade MySQL Schema'))
->setMessage(pht(
"Run the storage upgrade script to upgrade Phabricator's database ".
"schema. Missing patches: %s.",
implode(', ', array_keys($diff))))
->addCommand(
hsprintf('<tt>phabricator/ $</tt> ./bin/storage upgrade'));
}
}
}
}