Added indexes for speed

This commit is contained in:
snipe 2018-05-14 20:27:56 -07:00
parent 1f299ed73e
commit 05e3e6bda6
2 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddIndexes extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('action_logs', function (Blueprint $table) {
$table->index(['target_id', 'target_type']);
$table->index('created_at');
$table->index(['item_type', 'item_id', 'action_type']);
$table->index(['target_type', 'target_id', 'action_type']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('action_logs', function (Blueprint $table) {
$table->dropIndex(['target_id', 'target_type']);
$table->dropIndex(['created_at']);
$table->dropIndex(['item_type', 'item_id', 'action_type']);
$table->dropIndex(['target_type', 'target_id', 'action_type']);
});
}
}

View file

@ -0,0 +1,48 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddIndexesToAssets extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('assets', function (Blueprint $table) {
$table->index('created_at');
$table->index(['deleted_at', 'status_id']);
$table->index(['deleted_at', 'model_id']);
$table->index(['deleted_at', 'assigned_type', 'assigned_to']);
$table->index(['deleted_at', 'supplier_id']);
$table->index(['deleted_at', 'location_id']);
$table->index(['deleted_at', 'rtd_location_id']);
$table->index(['deleted_at', 'asset_tag']);
$table->index(['deleted_at', 'name']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('assets', function (Blueprint $table) {
$table->dropIndex(['created_at']);
$table->dropIndex(['deleted_at', 'status_id']);
$table->dropIndex(['deleted_at', 'model_id']);
$table->dropIndex(['deleted_at', 'assigned_type', 'assigned_to']);
$table->dropIndex(['deleted_at', 'supplier_id']);
$table->dropIndex(['deleted_at', 'location_id']);
$table->dropIndex(['deleted_at', 'rtd_location_id']);
$table->dropIndex(['deleted_at', 'asset_tag']);
$table->dropIndex(['deleted_at', 'name']);
});
}
}