mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Don't access the database too soon in Device model boot (#11453)
* Don't access the DB in Device model boot * check if db is migrated * use self * revert sensor link change
This commit is contained in:
@@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Database\Query\JoinClause;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\DB\Schema;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\Util\IP;
|
||||
use LibreNMS\Util\IPv4;
|
||||
@@ -35,7 +36,9 @@ class Device extends BaseModel
|
||||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
self::loadAllOs(true);
|
||||
if (Schema::isCurrent()) {
|
||||
self::loadAllOs(true);
|
||||
}
|
||||
|
||||
static::deleting(function (Device $device) {
|
||||
// delete related data
|
||||
|
||||
Reference in New Issue
Block a user