From 59a7b6de3694d97871b9023005236f1f9c9470d1 Mon Sep 17 00:00:00 2001 From: Filip Kojic Date: Wed, 4 Dec 2024 12:49:53 +0100 Subject: [PATCH 1/2] Fix reinstallation flow ISSUE: CS-6247 --- .../Migration1681716164AlterAdyenPayment.php | 15 +++++++++++++++ .../Migration1713255011AlterAdyenPayment.php | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/Migration/Migration1681716164AlterAdyenPayment.php b/src/Migration/Migration1681716164AlterAdyenPayment.php index 49efa04e..5d3d54a8 100644 --- a/src/Migration/Migration1681716164AlterAdyenPayment.php +++ b/src/Migration/Migration1681716164AlterAdyenPayment.php @@ -14,6 +14,21 @@ public function getCreationTimestamp(): int public function update(Connection $connection): void { + $schemaManager = $connection->createSchemaManager(); + + // check if table exists + if (!$schemaManager->tablesExist(['adyen_payment'])) { + return; + } + + // check if index already exists + $indexes = $schemaManager->listTableIndexes('adyen_payment'); + foreach ($indexes as $index) { + if ($index->getName() === 'UQ_ADYEN_PAYMENT_PSPREFERENCE') { + return; + } + } + $query = <<createSchemaManager(); + + // check if table exists + if (!$schemaManager->tablesExist(['adyen_payment'])) { + return; + } + + // check if column already exists + $columns = $schemaManager->listTableColumns('adyen_payment'); + if (array_key_exists('total_refunded', $columns)) { + return; + } + $connection->executeStatement(<< Date: Wed, 4 Dec 2024 13:55:15 +0100 Subject: [PATCH 2/2] Fix reinstallation flow by deleting all plugin tables ISSUE: CS-6247 --- src/AdyenPaymentShopware6.php | 8 +++++++- .../Migration1681716164AlterAdyenPayment.php | 15 --------------- .../Migration1713255011AlterAdyenPayment.php | 13 ------------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/AdyenPaymentShopware6.php b/src/AdyenPaymentShopware6.php index c11c9344..fb4eac65 100644 --- a/src/AdyenPaymentShopware6.php +++ b/src/AdyenPaymentShopware6.php @@ -25,9 +25,12 @@ namespace Adyen\Shopware; +use Adyen\Shopware\Entity\AdyenPayment\AdyenPaymentEntityDefinition; use Adyen\Shopware\Entity\Notification\NotificationEntityDefinition; +use Adyen\Shopware\Entity\PaymentCapture\PaymentCaptureEntityDefinition; use Adyen\Shopware\Entity\PaymentResponse\PaymentResponseEntityDefinition; use Adyen\Shopware\Entity\PaymentStateData\PaymentStateDataEntityDefinition; +use Adyen\Shopware\Entity\Refund\RefundEntityDefinition; use Adyen\Shopware\Handlers\KlarnaDebitRiskPaymentMethodHandler; use Adyen\Shopware\PaymentMethods\KlarnaDebitRiskPaymentMethod; use Adyen\Shopware\Service\ConfigurationService; @@ -278,7 +281,10 @@ private function removePluginData(): void $tables = [ NotificationEntityDefinition::ENTITY_NAME, PaymentStateDataEntityDefinition::ENTITY_NAME, - PaymentResponseEntityDefinition::ENTITY_NAME + PaymentResponseEntityDefinition::ENTITY_NAME, + AdyenPaymentEntityDefinition::ENTITY_NAME, + PaymentCaptureEntityDefinition::ENTITY_NAME, + RefundEntityDefinition::ENTITY_NAME ]; $connection = $this->container->get(Connection::class); foreach ($tables as $table) { diff --git a/src/Migration/Migration1681716164AlterAdyenPayment.php b/src/Migration/Migration1681716164AlterAdyenPayment.php index 5d3d54a8..49efa04e 100644 --- a/src/Migration/Migration1681716164AlterAdyenPayment.php +++ b/src/Migration/Migration1681716164AlterAdyenPayment.php @@ -14,21 +14,6 @@ public function getCreationTimestamp(): int public function update(Connection $connection): void { - $schemaManager = $connection->createSchemaManager(); - - // check if table exists - if (!$schemaManager->tablesExist(['adyen_payment'])) { - return; - } - - // check if index already exists - $indexes = $schemaManager->listTableIndexes('adyen_payment'); - foreach ($indexes as $index) { - if ($index->getName() === 'UQ_ADYEN_PAYMENT_PSPREFERENCE') { - return; - } - } - $query = <<createSchemaManager(); - - // check if table exists - if (!$schemaManager->tablesExist(['adyen_payment'])) { - return; - } - - // check if column already exists - $columns = $schemaManager->listTableColumns('adyen_payment'); - if (array_key_exists('total_refunded', $columns)) { - return; - } - $connection->executeStatement(<<