Add index on action_date, copy from created_at

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe
2025-03-06 16:01:46 +00:00
parent 8c164d1b09
commit 38efc62900
2 changed files with 37 additions and 0 deletions
+6
View File
@@ -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();
}
});
}
@@ -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
{
}
};