A free open source IT asset/license management system
Added indexes for speed
snipe05e3e6bda698
diff --git a/database/migrations/2018_05_14_215229_add_indexes.php b/database/migrations/2018_05_14_215229_add_indexes.phpnew file mode 100644index 0000000000..4f917f74e2--- /dev/null+++ b/database/migrations/2018_05_14_215229_add_indexes.php@@ -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']);+ });+ }+}diff --git a/database/migrations/2018_05_14_223646_add_indexes_to_assets.php b/database/migrations/2018_05_14_223646_add_indexes_to_assets.phpnew file mode 100644index 0000000000..a7161bdb53--- /dev/null+++ b/database/migrations/2018_05_14_223646_add_indexes_to_assets.php@@ -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']);+ });+ }+}