mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40: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:
parent
677f4ae83f
commit
c48bb5494a
1 changed files with 31 additions and 8 deletions
|
@ -15,16 +15,16 @@ final class PhabricatorSetupCheckDatabase extends PhabricatorSetupCheck {
|
|||
|
||||
ini_set('mysql.connect_timeout', 2);
|
||||
|
||||
$conn_raw = PhabricatorEnv::newObjectFromConfig(
|
||||
'mysql.implementation',
|
||||
array(
|
||||
array(
|
||||
$config = array(
|
||||
'user' => $conn_user,
|
||||
'pass' => $conn_pass,
|
||||
'host' => $conn_host,
|
||||
'database' => null,
|
||||
),
|
||||
));
|
||||
);
|
||||
|
||||
$conn_raw = PhabricatorEnv::newObjectFromConfig(
|
||||
'mysql.implementation',
|
||||
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'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue