Upgrading from commerce_paypal 8.x-1.0-beta4 to 8.x-1.0-beta8 we are seeing the following in the status report:
```
Mismatched entity and/or field definitions
The following changes were detected in the entity type and field definitions.
Payment method
The Card type field needs to be installed.
The Card number field needs to be installed.
The Card expiration month field needs to be installed.
The Card expiration year field needs to be installed.
```
It would appear that `drush entity-updates` has been removed by drupal. Other than installing devel do we have any other options?
I tried uninstalling commerce_paypal which resulted in the error:
```
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal.commerce_payment_method__card_type' doesn't exist: UPDATE {commerce_payment_method__card_type} SET deleted=:db_update_placeholder_0 WHERE bundle = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 1 [:db_condition_placeholder_0] => paypal_checkout ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->onFieldDefinitionDelete() (line 1636 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
```
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3157704-13.patch | 807 bytes | jsacksick |
Comments
Comment #2
jsacksick commentedHave you tried running the updates?
Comment #3
sittard commentedSorry yes should have mentioned, we ran the DB updates. No errors to report.
Comment #4
jsacksick commentedI'm not sure why your update failed... But basically this is what you need:
You could try running that again using drush php-eval.
Comment #5
sittard commentedThanks should I run that before or after the drupal db updates?
Comment #6
jsacksick commentedYou said you ran the drupal updates already?
Comment #7
sittard commentedYes I did but only in my testing environment so I can roll back the database if needed.
Comment #8
jsacksick commentedThat is the code that is supposed to install the payment method type (which is already present in the update hook).
Comment #9
sittard commentedI think I might have spotted a typo in:
https://git.drupalcode.org/project/commerce_paypal/-/blob/8.x-1.0-beta8/...
Around line 112 currently reads `uninstallBundles` I think this should be `installBundles` as per your example above. Would also explain why the update failed for me.
Comment #10
jsacksick commentedIt's not a typo, it might be affecting you because you're upgrading from beta4 to beta8, and a lot has changed since.
We used to use the payment method type that was then uninstalled, we're using it again now. I should probably have created a post update function instead of an update hook to install the bundle so it runs last.
Comment #11
sittard commentedThank you, I've now managed to install the payment method type but have hit a further error. The steps that I've followed are:
Drupal 8.8.8 / Drupal Commerce 8.x-2.20
1) Update drupal/commerce_paypal (1.0.0-beta4 => 1.0.0-beta8)
2) drush cr
3) run db update via gui (update.php) this updates as follows:
commerce_paypal module
- 8102 - Install the PayPal Checkout payment method type.
- Delete the PayPal Checkout payment methods.
- Uninstall the PayPal Checkout payment method type.
- Uninstall the flow field.
- Set the "payment_method_types" to "paypal_checkout".
> completes without error but reports mismatched entity (payment method) in status report
> database no longer has the commerce_payment_method__card tables
4) drush php-eval '$entity_type = \Drupal::entityTypeManager()->getDefinition("commerce_payment_method"); \Drupal::service("entity.bundle_plugin_installer")->installBundles($entity_type, ["commerce_paypal"]);'
> creates payment method type and resolves missing entity issue
> database now has commerce_payment_method__card tables (but they contain null data)
All looks good but now when I navigate to admin/commerce/orders we get the following error:
It would appear that I can view historical PayPal orders via admin/commerce/orders/123 but if the payment method for the order is Credit or Debit Card (Braintree) then we get the above error message. Which I'm guessing is a result of the commerce_payment_method__card tables being purged.
Thanks.
Comment #12
jsacksick commentedThanks for this detailed report... One of the mistakes that was probably made was to reuse the same payment method type we previously had and was uninstalled.
The payment method type initially uninstalled defined different fields that are no longer needed.
Because the payment method type now extends
CreditCard, running the post update functions actually uninstalls fields defined by the CreditCard plugin (not the previous fields that we intended to remove in the first place)....I'm wondering if we should simply empty the post update function that contains payment method type uninstallation. That should fix it, and prevent issues with people upgrading from earlier versions.
Comment #13
jsacksick commentedCould you try rerunning everything after applying the attached patch?
Comment #14
jsacksick commentedI'm pretty sure the patch would fix the issue, and I'm tempted to tag a new beta right after committing it so that people upgrading from "old" beta versions don't experience the same error.
Comment #15
sittard commentedThanks - I should be able to test the patch later today if that helps.
Comment #17
jsacksick commentedOk, I actually went ahead and tagged a new release that includes this fix since I consider this a "major" issue that can result in data loss.
Comment #18
sittard commentedJust confirming the update from 1.0.0-beta4 => 1.0.0-beta9 works without error or issue.
Many Thanks
Comment #19
jsacksick commentedAwesome! Thanks for confirming.