new index in alert_log table (#12143)

* new index in alert_log table

* codefix1

* codefix2

* added second index

* codefix

* Apply suggestions from code review

Co-authored-by: Jellyfrog <Jellyfrog@users.noreply.github.com>
This commit is contained in:
Negatifff
2020-09-24 18:05:21 +03:00
committed by GitHub
parent 87538c4c4a
commit 444b9544a0
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddAlertLogIndex extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('alert_log', function (Blueprint $table) {
$table->index(['rule_id', 'device_id']);
$table->index(['rule_id', 'device_id', 'state']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('alert_log', function (Blueprint $table) {
$table->dropIndex(['rule_id', 'device_id']);
$table->dropIndex(['rule_id', 'device_id', 'state']);
});
}
}

View File

@ -72,6 +72,8 @@ alert_log:
alert_log_device_id_index: { Name: alert_log_device_id_index, Columns: [device_id], Unique: false, Type: BTREE }
alert_log_rule_id_index: { Name: alert_log_rule_id_index, Columns: [rule_id], Unique: false, Type: BTREE }
alert_log_time_logged_index: { Name: alert_log_time_logged_index, Columns: [time_logged], Unique: false, Type: BTREE }
alert_log_rule_id_device_id_index: { Name: alert_log_rule_id_device_id_index, Columns: [rule_id, device_id], Unique: false, Type: BTREE }
alert_log_rule_id_device_id_state_index: { Name: alert_log_rule_id_device_id_state_index, Columns: [rule_id, device_id, state], Unique: false, Type: BTREE }
alert_rules:
Columns:
- { Field: id, Type: 'int unsigned', 'Null': false, Extra: auto_increment }