diff --git a/database/migrations/2020_09_22_172321_add_alert_log_index.php b/database/migrations/2020_09_22_172321_add_alert_log_index.php new file mode 100644 index 0000000000..bd0022248e --- /dev/null +++ b/database/migrations/2020_09_22_172321_add_alert_log_index.php @@ -0,0 +1,34 @@ +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']); + }); + } +} diff --git a/misc/db_schema.yaml b/misc/db_schema.yaml index fc22af61e2..65a9d820e3 100644 --- a/misc/db_schema.yaml +++ b/misc/db_schema.yaml @@ -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 }