LMS/database/migrations/2024_01_05_000003_create_lo...

36 lines
1.1 KiB
PHP
Executable File

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('logs', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained()->onDelete('set null');
$table->string('log_type');
$table->string('description');
$table->string('loggable_type')->nullable();
$table->unsignedBigInteger('loggable_id')->nullable();
$table->json('old_values')->nullable();
$table->json('new_values')->nullable();
$table->string('ip_address')->nullable();
$table->text('user_agent')->nullable();
$table->timestamps();
$table->index('user_id');
$table->index('log_type');
$table->index(['loggable_type', 'loggable_id']);
$table->index('created_at');
});
}
public function down(): void
{
Schema::dropIfExists('logs');
}
};