Install: Validate database before migrating (#12867)

* Validate database during install
Needed to remove usages of legacy functions in the validation

* Fix output, restore real versions
This commit is contained in:
Tony Murray
2021-05-13 07:18:54 -05:00
committed by GitHub
parent 500b0ac6fa
commit df5096e449
15 changed files with 77 additions and 69 deletions

View File

@@ -28,6 +28,7 @@ use DB;
use Illuminate\Support\Str;
use LibreNMS\Config;
use LibreNMS\Util\Version;
use PDOException;
use Schema as LaravelSchema;
use Symfony\Component\Yaml\Yaml;
@@ -111,6 +112,25 @@ class Schema
return $this->schema;
}
/**
* Get the schema version from the previous schema system
*/
public static function getLegacySchema(): int
{
try {
$db = \LibreNMS\DB\Eloquent::DB();
if ($db) {
return (int) $db->table('dbSchema')
->orderBy('version', 'DESC')
->value('version');
}
} catch (PDOException $e) {
// return default
}
return 0;
}
/**
* Get a list of all tables.
*