chore(admin): activity logs (#1197)

This commit is contained in:
Kyrch
2026-05-07 21:33:57 -03:00
committed by GitHub
parent f5e098875f
commit a3f1a8c7e3
40 changed files with 428 additions and 896 deletions
@@ -1,39 +0,0 @@
<?php
declare(strict_types=1);
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
{
if (! Schema::hasTable('action_logs')) {
Schema::create('action_logs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('batch_id');
$table->unsignedBigInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->nullOnDelete();
$table->string('name');
$table->morphs('actionable');
$table->morphs('target');
$table->string('model_type');
$table->uuid('model_id')->nullable();
$table->integer('status')->nullable();
$table->json('fields')->nullable();
$table->text('exception')->nullable();
$table->timestamps(6);
$table->timestamp('finished_at', 6)->nullable();
$table->index(['batch_id', 'model_type', 'model_id']);
});
}
}
};
@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('activity_log')) {
Schema::create('activity_log', function (Blueprint $table) {
$table->id();
$table->string('log_name')->nullable()->index();
$table->text('description');
$table->nullableMorphs('subject', 'subject');
$table->nullableMorphs('related', 'related');
$table->string('event')->nullable();
$table->nullableMorphs('causer', 'causer');
$table->json('attribute_changes')->nullable();
$table->json('properties')->nullable();
$table->integer('status')->nullable();
$table->text('exception')->nullable();
$table->timestamps(6);
$table->timestamp('finished_at', 6)->nullable();
});
}
}
};