#feature: add ip operation log & sql generator

This commit is contained in:
2025-12-25 14:25:57 +08:00
parent 79889e1040
commit 3bcbd0661f
21 changed files with 1751 additions and 21 deletions

View File

@@ -0,0 +1,24 @@
<?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('ip_user_mappings', function (Blueprint $table): void {
$table->id();
$table->string('ip_address', 64)->unique();
$table->string('user_name', 128);
$table->string('remark', 255)->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('ip_user_mappings');
}
};

View File

@@ -0,0 +1,33 @@
<?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('operation_logs', function (Blueprint $table): void {
$table->id();
$table->string('ip_address', 64);
$table->string('user_label', 128)->nullable();
$table->string('method', 10);
$table->string('path', 255);
$table->string('route_name', 255)->nullable();
$table->unsignedSmallInteger('status_code');
$table->unsignedInteger('duration_ms')->default(0);
$table->json('request_payload')->nullable();
$table->string('user_agent', 255)->nullable();
$table->timestamps();
$table->index(['ip_address', 'created_at']);
$table->index(['user_label', 'created_at']);
});
}
public function down(): void
{
Schema::dropIfExists('operation_logs');
}
};