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:
Tony Murray
2020-04-21 10:19:25 -05:00
committed by GitHub
parent cc60a76c7b
commit 4833edb7d6
+4 -1
View File
@@ -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