From c48bb5494a0e307828f9d10b503b231f35cfda42 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 9 Apr 2013 21:37:20 -0700 Subject: [PATCH] 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 --- .../check/PhabricatorSetupCheckDatabase.php | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/applications/config/check/PhabricatorSetupCheckDatabase.php b/src/applications/config/check/PhabricatorSetupCheckDatabase.php index d966b19b97..be768e0c8f 100644 --- a/src/applications/config/check/PhabricatorSetupCheckDatabase.php +++ b/src/applications/config/check/PhabricatorSetupCheckDatabase.php @@ -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('phabricator/ $ ./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('phabricator/ $ ./bin/storage upgrade')); + } } } }