Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/check/PhabricatorDatabaseSetupCheck.php
Show All 29 Lines | if (preg_match('/^([^:]+):(\d+)$/', $host, $matches)) { | ||||
'Your `%s` configuration contains a port number, but this usage '. | 'Your `%s` configuration contains a port number, but this usage '. | ||||
'is deprecated. Instead, put the port number in `%s`.', | 'is deprecated. Instead, put the port number in `%s`.', | ||||
'mysql.host', | 'mysql.host', | ||||
'mysql.port')) | 'mysql.port')) | ||||
->addPhabricatorConfig('mysql.host') | ->addPhabricatorConfig('mysql.host') | ||||
->addPhabricatorConfig('mysql.port') | ->addPhabricatorConfig('mysql.port') | ||||
->addCommand( | ->addCommand( | ||||
hsprintf( | hsprintf( | ||||
'<tt>phabricator/ $</tt> ./bin/config set mysql.host %s', | '<tt>$</tt> ./bin/config set mysql.host %s', | ||||
$host)) | $host)) | ||||
->addCommand( | ->addCommand( | ||||
hsprintf( | hsprintf( | ||||
'<tt>phabricator/ $</tt> ./bin/config set mysql.port %s', | '<tt>$</tt> ./bin/config set mysql.port %s', | ||||
$port)); | $port)); | ||||
} | } | ||||
$refs = PhabricatorDatabaseRef::queryAll(); | $refs = PhabricatorDatabaseRef::queryAll(); | ||||
$refs = mpull($refs, null, 'getRefKey'); | $refs = mpull($refs, null, 'getRefKey'); | ||||
// Test if we can connect to each database first. If we can not connect | // Test if we can connect to each database first. If we can not connect | ||||
// to a particular database, we only raise a warning: this allows new web | // to a particular database, we only raise a warning: this allows new web | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | if (empty($databases[$namespace.'_meta_data'])) { | ||||
'Run the storage upgrade script to setup databases (host "%s" has '. | 'Run the storage upgrade script to setup databases (host "%s" has '. | ||||
'not been initialized).', | 'not been initialized).', | ||||
$ref_key); | $ref_key); | ||||
$this->newIssue('storage.upgrade') | $this->newIssue('storage.upgrade') | ||||
->setName(pht('Setup MySQL Schema')) | ->setName(pht('Setup MySQL Schema')) | ||||
->setMessage($message) | ->setMessage($message) | ||||
->setIsFatal(true) | ->setIsFatal(true) | ||||
->addCommand(hsprintf('<tt>phabricator/ $</tt> ./bin/storage upgrade')); | ->addCommand(hsprintf('<tt>$</tt> ./bin/storage upgrade')); | ||||
return true; | return true; | ||||
} | } | ||||
$conn_meta = $ref->newApplicationConnection( | $conn_meta = $ref->newApplicationConnection( | ||||
$namespace.'_meta_data'); | $namespace.'_meta_data'); | ||||
$applied = queryfx_all($conn_meta, 'SELECT patch FROM patch_status'); | $applied = queryfx_all($conn_meta, 'SELECT patch FROM patch_status'); | ||||
Show All 9 Lines | if ($diff) { | ||||
$ref_key, | $ref_key, | ||||
implode(', ', array_keys($diff))); | implode(', ', array_keys($diff))); | ||||
$this->newIssue('storage.patch') | $this->newIssue('storage.patch') | ||||
->setName(pht('Upgrade MySQL Schema')) | ->setName(pht('Upgrade MySQL Schema')) | ||||
->setIsFatal(true) | ->setIsFatal(true) | ||||
->setMessage($message) | ->setMessage($message) | ||||
->addCommand( | ->addCommand( | ||||
hsprintf('<tt>phabricator/ $</tt> ./bin/storage upgrade')); | hsprintf('<tt>$</tt> ./bin/storage upgrade')); | ||||
return true; | return true; | ||||
} | } | ||||
// NOTE: It's possible that replication is broken but we have not been | // NOTE: It's possible that replication is broken but we have not been | ||||
// granted permission to "SHOW SLAVE STATUS" so we can't figure it out. | // granted permission to "SHOW SLAVE STATUS" so we can't figure it out. | ||||
// We allow this kind of configuration and survive these checks, trusting | // We allow this kind of configuration and survive these checks, trusting | ||||
// that operations knows what they're doing. This issue is shown on the | // that operations knows what they're doing. This issue is shown on the | ||||
// "Database Servers" console. | // "Database Servers" console. | ||||
switch ($ref->getReplicaStatus()) { | switch ($ref->getReplicaStatus()) { | ||||
case PhabricatorDatabaseRef::REPLICATION_MASTER_REPLICA: | case PhabricatorDatabaseRef::REPLICATION_MASTER_REPLICA: | ||||
$message = pht( | $message = pht( | ||||
'Database host "%s" is configured as a master, but is replicating '. | 'Database host "%s" is configured as a master, but is replicating '. | ||||
'another host. This is dangerous and can mangle or destroy data. '. | 'another host. This is dangerous and can mangle or destroy data. '. | ||||
'Only replicas should be replicating. Stop replication on the '. | 'Only replicas should be replicating. Stop replication on the '. | ||||
'host or reconfigure Phabricator.', | 'host or adjust configuration.', | ||||
$ref->getRefKey()); | $ref->getRefKey()); | ||||
$this->newIssue('db.master.replicating') | $this->newIssue('db.master.replicating') | ||||
->setName(pht('Replicating Master')) | ->setName(pht('Replicating Master')) | ||||
->setIsFatal(true) | ->setIsFatal(true) | ||||
->setMessage($message); | ->setMessage($message); | ||||
return true; | return true; | ||||
▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0