A free open source IT asset/license management system
Add index on action_date, copy from created_at
snipe38efc6290036
diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.phpindex a14910208e..67f30701c3 100755--- a/app/Models/Actionlog.php+++ b/app/Models/Actionlog.php@@ -93,7 +93,13 @@ class Actionlog extends SnipeModel} elseif (auth()->user() && auth()->user()->company) {$actionlog->company_id = auth()->user()->company_id;}++ if ($actionlog->action_date == '') {+ $actionlog->action_date = Carbon::now();+ }+});+}diff --git a/database/migrations/2025_03_06_152922_copy_created_at_to_action_date_in_action_logs.php b/database/migrations/2025_03_06_152922_copy_created_at_to_action_date_in_action_logs.phpnew file mode 100644index 0000000000..8ce7de13bd--- /dev/null+++ b/database/migrations/2025_03_06_152922_copy_created_at_to_action_date_in_action_logs.php@@ -0,0 +1,31 @@+<?php++use Illuminate\Database\Migrations\Migration;+use Illuminate\Support\Facades\DB;+use Illuminate\Database\Schema\Blueprint;+use Illuminate\Support\Facades\Schema;++return new class extends Migration+{+ /**+ * Run the migrations.+ */+ public function up(): void+ {++ Schema::table('action_logs', function (Blueprint $table) {+ $table->index(['action_date']);+ });++ DB::update('update '.DB::getTablePrefix().'action_logs set action_date = created_at where created_at IS NOT NULL and action_date IS NULL');++ }++ /**+ * Reverse the migrations.+ */+ public function down(): void+ {++ }+};