<?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
    {
        Schema::create('presence_fingerprints', function (Blueprint $table) {
            $table->id();
            $table->string('fingerprint', 64)->unique();
            $table->string('token', 64)->index();
            $table->timestamp('expires_at')->index();
            $table->string('socket_id', 100)->nullable()->index();
            $table->timestamps();

            // Foreign key constraint (optional, untuk referential integrity)
            // Note: Using string token instead of foreignId because token is string
            // We'll handle referential integrity at application level
        });
    }

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