mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
"Disable alerting" on device disables alert rules check (not just alert transport) (#11015)
* Fix disable notify * Fix disable notify * Disable all alerting * fix db migration * fix db migration * fix db migration * Add autoclearing active alerts if disable alerting set * Add autoclearing active alerts if disable alerting set * fix check * Device in gray if disable_notify is set - not ignore tag
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class MigrateDevicesAttribsTable extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
$table->boolean('disable_notify')->default(0);
|
||||
});
|
||||
// migrate disable_notify data into devices table
|
||||
\DB::statement("UPDATE devices d, devices_attribs da SET d.disable_notify=1 WHERE da.attrib_type='disable_notify' AND da.attrib_value=1 AND d.device_id = da.device_id;");
|
||||
\DB::statement("DELETE FROM devices_attribs WHERE attrib_type='disable_notify' AND attrib_value=1;");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
// revert migrate disable_notify data into devices table
|
||||
\DB::statement("INSERT INTO devices_attribs (device_id, attrib_type, attrib_value) SELECT DISTINCT d.device_id, 'disable_notify', 1 FROM devices_attribs da INNER JOIN devices d WHERE d.device_id = da.device_id AND d.disable_notify=1;");
|
||||
Schema::table('devices', function (Blueprint $table) {
|
||||
$table->dropColumn('disable_notify');
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user