|
@@ -0,0 +1,30 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
+use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
+use Illuminate\Support\Facades\Schema;
|
|
|
|
|
+
|
|
|
|
|
+return new class extends Migration
|
|
|
|
|
+{
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Hash determinístico da api_key para detectar unidades que compartilham a
|
|
|
|
|
+ * MESMA conta Asaas (mesmo dono). Como a api_key é cifrada (IV aleatório),
|
|
|
|
|
+ * não dá para comparar por SQL — o hash resolve isso e permite reaproveitar
|
|
|
|
|
+ * um único webhook por conta.
|
|
|
|
|
+ */
|
|
|
|
|
+ public function up(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ Schema::table('unit_payment_accounts', function (Blueprint $table) {
|
|
|
|
|
+ $table->string('asaas_api_key_hash')->nullable()->after('asaas_webhook_id');
|
|
|
|
|
+ $table->index('asaas_api_key_hash');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function down(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ Schema::table('unit_payment_accounts', function (Blueprint $table) {
|
|
|
|
|
+ $table->dropIndex(['asaas_api_key_hash']);
|
|
|
|
|
+ $table->dropColumn('asaas_api_key_hash');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+};
|