<?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('voter_search_logs', function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->foreignUuid('desa_id')->constrained('desa')->cascadeOnDelete();
            $table->string('ip_hash', 64);
            $table->enum('query_type', ['nama', 'nik']);
            $table->string('query_masked');
            $table->integer('result_count')->default(0);
            $table->timestamp('created_at')->nullable();
        });
    }

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