<?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('earn_audits', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('earn_member_id')->nullable()->constrained()->nullOnDelete();
            $table->string('event', 50)->index();
            $table->ipAddress('ip_address')->nullable();
            $table->json('metadata')->nullable();
            $table->timestamp('created_at')->useCurrent();
        });
    }

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