Skip to content

A free open source IT asset/license management system

Added composite index to assets

snipe8214c6527aa7
diff --git a/database/migrations/2026_09_22_201800_add_deleted_at_created_at_composite_index_to_assets.php b/database/migrations/2026_09_22_201800_add_deleted_at_created_at_composite_index_to_assets.php
new file mode 100644
index 0000000000..f1605abdff
--- /dev/null
+++ b/database/migrations/2026_09_22_201800_add_deleted_at_created_at_composite_index_to_assets.php
@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::table('assets', function (Blueprint $table) {
+ // This composite lets the optimizer walk the deleted_at=NULL slice
+ // in created_at order and handle the WHERE + ORDER BY + LIMIT together
+ $table->index(['deleted_at', 'created_at']);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('assets', function (Blueprint $table) {
+ $table->dropIndex(['deleted_at', 'created_at']);
+ });
+ }
+};