fix: UNIQUE en pagos_confirmados.email_hash previene doble crédito por race condition

Sin este índice, dos procesos PHP simultáneos podían pasar el check yaUsado()
ambos con false y marcar el mismo hash dos veces, aplicando la recarga doble.
Con UNIQUE, el segundo INSERT falla y el catch existente lo bloquea (falla cerrado).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro
2026-07-19 15:45:15 +00:00
co-authored by Claude Sonnet 4.6
parent bb311e7dcd
commit 3ee850776b
@@ -0,0 +1,22 @@
<?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::table('pagos_confirmados', function (Blueprint $table) {
$table->unique('email_hash');
});
}
public function down(): void
{
Schema::table('pagos_confirmados', function (Blueprint $table) {
$table->dropUnique(['email_hash']);
});
}
};