mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user