From 05e3e6bda698503229af1e92d4e1a46044bdab34 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 14 May 2018 20:27:56 -0700 Subject: [PATCH] Added indexes for speed --- .../2018_05_14_215229_add_indexes.php | 39 +++++++++++++++ ...018_05_14_223646_add_indexes_to_assets.php | 48 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 database/migrations/2018_05_14_215229_add_indexes.php create mode 100644 database/migrations/2018_05_14_223646_add_indexes_to_assets.php diff --git a/database/migrations/2018_05_14_215229_add_indexes.php b/database/migrations/2018_05_14_215229_add_indexes.php new file mode 100644 index 0000000000..4f917f74e2 --- /dev/null +++ b/database/migrations/2018_05_14_215229_add_indexes.php @@ -0,0 +1,39 @@ +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.php new file mode 100644 index 0000000000..a7161bdb53 --- /dev/null +++ b/database/migrations/2018_05_14_223646_add_indexes_to_assets.php @@ -0,0 +1,48 @@ +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']); + }); + } +}