diff --git a/database/migrations/2025_10_02_000020_add_unique_index_payments_account_reference.php b/database/migrations/2025_10_02_000020_add_unique_index_payments_account_reference.php deleted file mode 100644 index 4d869b1..0000000 --- a/database/migrations/2025_10_02_000020_add_unique_index_payments_account_reference.php +++ /dev/null @@ -1,41 +0,0 @@ -hasUniqueIndex('payments', 'payments_account_id_reference_unique')) { - $table->unique(['account_id', 'reference'], 'payments_account_id_reference_unique'); - } - }); - } - - public function down(): void - { - Schema::table('payments', function (Blueprint $table): void { - if ($this->hasUniqueIndex('payments', 'payments_account_id_reference_unique')) { - $table->dropUnique('payments_account_id_reference_unique'); - } - }); - } - - private function hasUniqueIndex(string $table, string $indexName): bool - { - // Works for both SQLite and others by checking existing indexes from connection schema manager when available. - try { - $connection = Schema::getConnection(); - $schemaManager = $connection->getDoctrineSchemaManager(); - $indexes = $schemaManager->listTableIndexes($table); - - return array_key_exists($indexName, $indexes); - } catch (\Throwable $e) { - // Fallback: attempt dropping/creating blindly in migration operations - return false; - } - } -};