<?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('admin_activity_log', function (Blueprint $table) {
            $table->id();
            $table->foreignId('admin_id')->constrained('admins')->cascadeOnDelete();
            $table->string('action'); // e.g. points.credit, member.suspend, tier.upgrade
            $table->string('target_type')->nullable(); // e.g. App\Models\User
            $table->unsignedBigInteger('target_id')->nullable();
            $table->json('meta')->nullable(); // additional context
            $table->string('ip_address', 45)->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('admin_activity_log');
    }
};
