<?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('reset_password_attempts', function (Blueprint $table): void {
            $table->id();
            $table->foreignId('user_id')
                ->constrained()
                ->cascadeOnUpdate()
                ->cascadeOnDelete();
            $table->string('codigo');
            $table->string('status')->default('pending');

            $table->index(['user_id', 'codigo', 'status']);
        });
    }

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