<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        if (!Schema::hasTable('request_data_logs')) {
            Schema::create('request_data_logs', function (Blueprint $table) {
                $table->id();
                $table->string('product_slug');
                $table->string('purchase_code');
                $table->string('request_method');
                $table->string('domain');
                $table->string('path');
                $table->string('user_agent');
                $table->ipAddress('end_user_ip');
                $table->timestamp('request_timestamp');
                $table->ipAddress('host_server_ip')->nullable();
                $table->timestamps();
            });
        }

    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        if (Schema::hasTable('request_data_logs')) {
            Schema::dropIfExists('request_data_logs');
        }
    }
};
