This commit is contained in:
2026-03-17 15:55:13 +08:00
parent 4eb74366ec
commit b34c44a590
5 changed files with 575 additions and 0 deletions
@@ -0,0 +1,39 @@
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('operation_logs', function (Blueprint $table) {
$table->id()->comment('主键');
$table->unsignedBigInteger('user_id')->comment('操作用户 ID');
$table->string('action', 50)->comment('操作类型');
$table->string('target_type', 50)->comment('操作目标类型');
$table->unsignedBigInteger('target_id')->nullable()->comment('操作目标 ID');
$table->string('description', 500)->comment('操作描述');
$table->jsonb('detail')->nullable()->comment('操作详情');
$table->string('ip', 45)->nullable()->comment('客户端 IP');
$table->timestampTz('created_at')->useCurrent()->comment('创建时间');
$table->index('user_id');
$table->index('action');
$table->index(['target_type', 'target_id']);
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('operation_logs');
}
};