Fix installer when DB is empty (#12873)

(which is every time)
This commit is contained in:
Tony Murray
2021-05-13 13:02:43 -05:00
committed by GitHub
parent 5ba3df45eb
commit 77a17dac88
2 changed files with 19 additions and 7 deletions

View File

@@ -50,12 +50,24 @@ class Database extends BaseValidation
return;
}
$this->validateSystem($validator);
if ($this->checkSchemaVersion($validator)) {
$this->checkSchema($validator);
$this->checkCollation($validator);
}
}
public function validateSystem(Validator $validator)
{
$this->checkVersion($validator);
$this->checkMode($validator);
$this->checkTime($validator);
$this->checkMysqlEngine($validator);
}
// check database schema version
private function checkSchemaVersion(Validator $validator): bool
{
$current = \LibreNMS\DB\Schema::getLegacySchema();
$latest = 1000;
@@ -64,7 +76,7 @@ class Database extends BaseValidation
if (! Schema::isCurrent()) {
$validator->fail('Your database is out of date!', './lnms migrate');
return;
return false;
}
$migrations = Schema::getUnexpectedMigrations();
@@ -78,13 +90,12 @@ class Database extends BaseValidation
'Manually run ./daily.sh, and check for any errors.'
);
return;
return false;
} 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.");
}
$this->checkCollation($validator);
$this->checkSchema($validator);
return true;
}
private function checkVersion(Validator $validator)

View File

@@ -31,6 +31,7 @@ use LibreNMS\DB\Eloquent;
use LibreNMS\DB\Schema;
use LibreNMS\Interfaces\InstallerStep;
use LibreNMS\ValidationResult;
use LibreNMS\Validations\Database;
use LibreNMS\Validator;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -75,7 +76,7 @@ class DatabaseController extends InstallationController implements InstallerStep
// validate Database
$validator = new Validator();
$validator->validate(['database']);
(new Database())->validateSystem($validator);
$results = $validator->getResults('database');
/** @var \LibreNMS\ValidationResult $result */