Skip to content

Commit 5500c20

Browse files
fahuFabian Hurnauscandemiralp
authored
Make VaultMigration compatible with disabled/removed Magento PayPal module (#2806)
* Make VaultMigration compatible with disabled/removed Magento PayPal module **Issue** The installation/upgrade of the Adyen Payment plugin fails with the following error: ``` Column not found: 1054 Unknown column 'method_code' in 'where clause', query was: SELECT `paypal_billing_agreement`.* FROM `paypal_billing_agreement` WHERE (method_code = 'adyen_oneclick') AND (status = 'active') ``` **Cause** The Adyen Payment module re-creates the table during migration by adding the agreement_data field (via db_schema.xml). However, when attempting to migrate the billing agreements to the vault, the process fails to query the table using the `method_code` and `status` because these fields do not exist in the table. **Solution** Ensure VaultMigration does not fail if the `paypal_billing_agreement` table is missing or required fields are missing. * Use getTableName() method to obtain the full table name containing table prefix * Revert "Use getTableName() method to obtain the full table name containing table prefix" This reverts commit e59cbbc. * Drop `paypal_billing_agreement.agreement_data` declaration * Bump MariaDB version * Use connection to check the existence of the table --------- Co-authored-by: Fabian Hurnaus <fabian.hurnaus@tractive.com> Co-authored-by: Can Demiralp <ecandemiralp@gmail.com> Co-authored-by: Can Demiralp <can.demiralp@adyen.com>
1 parent 9056277 commit 5500c20

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.github/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '3'
22

33
services:
44
db:
5-
image: mariadb:10.4
5+
image: mariadb:11.4
66
container_name: mariadb
77
networks:
88
- backend

Setup/Patch/Data/VaultMigration.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ public function apply(): void
5656

5757
private function migrateBillingAgreementsToVault(ModuleDataSetupInterface $setup): void
5858
{
59+
if (!$setup->getConnection()->isTableExists('paypal_billing_agreement')) {
60+
$this->adyenLogger->addAdyenInfoLog('Table paypal_billing_agreement does not exist, skipping migration');
61+
return;
62+
}
63+
64+
$columns = $setup->getConnection()->describeTable('paypal_billing_agreement');
65+
if (!isset($columns['method_code']) || !isset($columns['status'])) {
66+
$this->adyenLogger->addAdyenInfoLog('Columns method_code and status do not exist, skipping migration');
67+
return;
68+
}
69+
5970
$paypalTable = $setup->getTable('paypal_billing_agreement');
6071
$connection = $setup->getConnection();
6172

etc/db_schema.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
<table name="sales_order_payment" resource="default">
1010
<column xsi:type="varchar" name="adyen_psp_reference" nullable="true" length="255" comment="Adyen PspReference of the payment"/>
1111
</table>
12-
<table name="paypal_billing_agreement" resource="default">
13-
<column xsi:type="text" name="agreement_data" nullable="true" comment="Agreement Data"/>
14-
</table>
1512
<table name="adyen_order_payment" resource="default" engine="innodb" comment="Adyen Order Payment">
1613
<column xsi:type="int" name="entity_id" padding="10" unsigned="true" nullable="false" identity="true" comment="Adyen Payment ID"/>
1714
<column xsi:type="varchar" name="pspreference" nullable="false" length="255" comment="Pspreference"/>

0 commit comments

Comments
 (0)