Skip to content

A free open source IT asset/license management system

Add index to 'parent_id' for users with large number of locations

Brady Wetherington28b450fd3cb1
diff --git a/database/migrations/2024_05_27_143554_add_parent_id_index_to_locations.php b/database/migrations/2024_05_27_143554_add_parent_id_index_to_locations.php
new file mode 100644
index 0000000000..2aef11918f
--- /dev/null
+++ b/database/migrations/2024_05_27_143554_add_parent_id_index_to_locations.php
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AddParentIdIndexToLocations extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('locations', function (Blueprint $table) {
+ $table->index('parent_id');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('locations', function (Blueprint $table) {
+ //
+ $table->dropIndex('locations_parent_id_index');
+ });
+ }
+}