<?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('callback_requests', function (Blueprint $table) {
            $table->charset = 'utf8mb4';
            $table->collation = 'utf8mb4_unicode_ci';
            $table->id();
            $table->string('name', 120);
            $table->string('mobile', 30);
            $table->string('locale', 5)->default('en');
            $table->string('source_page')->nullable();
            $table->string('source_url', 1024)->nullable();
            $table->string('ip_address', 45)->nullable();
            $table->text('user_agent')->nullable();
            $table->timestamp('created_at')->useCurrent();

            $table->index('mobile', 'callback_requests_mobile_index');
            $table->index('created_at', 'callback_requests_created_at_index');
            $table->index('locale', 'callback_requests_locale_index');
            $table->index('source_page', 'callback_requests_source_page_index');
        });
    }

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