mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
@@ -50,12 +50,24 @@ class Database extends BaseValidation
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->validateSystem($validator);
|
||||||
|
|
||||||
|
if ($this->checkSchemaVersion($validator)) {
|
||||||
|
$this->checkSchema($validator);
|
||||||
|
$this->checkCollation($validator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validateSystem(Validator $validator)
|
||||||
|
{
|
||||||
$this->checkVersion($validator);
|
$this->checkVersion($validator);
|
||||||
$this->checkMode($validator);
|
$this->checkMode($validator);
|
||||||
$this->checkTime($validator);
|
$this->checkTime($validator);
|
||||||
$this->checkMysqlEngine($validator);
|
$this->checkMysqlEngine($validator);
|
||||||
|
}
|
||||||
|
|
||||||
// check database schema version
|
private function checkSchemaVersion(Validator $validator): bool
|
||||||
|
{
|
||||||
$current = \LibreNMS\DB\Schema::getLegacySchema();
|
$current = \LibreNMS\DB\Schema::getLegacySchema();
|
||||||
$latest = 1000;
|
$latest = 1000;
|
||||||
|
|
||||||
@@ -64,7 +76,7 @@ class Database extends BaseValidation
|
|||||||
if (! Schema::isCurrent()) {
|
if (! Schema::isCurrent()) {
|
||||||
$validator->fail('Your database is out of date!', './lnms migrate');
|
$validator->fail('Your database is out of date!', './lnms migrate');
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$migrations = Schema::getUnexpectedMigrations();
|
$migrations = Schema::getUnexpectedMigrations();
|
||||||
@@ -78,13 +90,12 @@ class Database extends BaseValidation
|
|||||||
'Manually run ./daily.sh, and check for any errors.'
|
'Manually run ./daily.sh, and check for any errors.'
|
||||||
);
|
);
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
} elseif ($current > $latest) {
|
} elseif ($current > $latest) {
|
||||||
$validator->warn("Your database schema ($current) is newer than expected ($latest). If you just switched to the stable release from the daily release, your database is in between releases and this will be resolved with the next release.");
|
$validator->warn("Your database schema ($current) is newer than expected ($latest). If you just switched to the stable release from the daily release, your database is in between releases and this will be resolved with the next release.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->checkCollation($validator);
|
return true;
|
||||||
$this->checkSchema($validator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkVersion(Validator $validator)
|
private function checkVersion(Validator $validator)
|
||||||
|
@@ -31,6 +31,7 @@ use LibreNMS\DB\Eloquent;
|
|||||||
use LibreNMS\DB\Schema;
|
use LibreNMS\DB\Schema;
|
||||||
use LibreNMS\Interfaces\InstallerStep;
|
use LibreNMS\Interfaces\InstallerStep;
|
||||||
use LibreNMS\ValidationResult;
|
use LibreNMS\ValidationResult;
|
||||||
|
use LibreNMS\Validations\Database;
|
||||||
use LibreNMS\Validator;
|
use LibreNMS\Validator;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ class DatabaseController extends InstallationController implements InstallerStep
|
|||||||
|
|
||||||
// validate Database
|
// validate Database
|
||||||
$validator = new Validator();
|
$validator = new Validator();
|
||||||
$validator->validate(['database']);
|
(new Database())->validateSystem($validator);
|
||||||
$results = $validator->getResults('database');
|
$results = $validator->getResults('database');
|
||||||
|
|
||||||
/** @var \LibreNMS\ValidationResult $result */
|
/** @var \LibreNMS\ValidationResult $result */
|
||||||
|
Reference in New Issue
Block a user