easy-digital-downloads
easy-digital-downloads copied to clipboard
Review customer address migration for EDD 3.0
A customer reported that this step of the EDD 3.0 migration via CLI was never completing and locking his site.
He updated the query to this and it was able to complete:
UPDATE wp_edd_customer_addresses ca
SET ca.is_primary = 1
WHERE ca.id IN (
SELECT MAX(ca2.id)
FROM ( SELECT id, customer_id FROM wp_edd_customer_addresses WHERE type = 'billing' ) ca2
GROUP BY ca2.customer_id
)
However, looking at the customer_addresses method in the data migrator class, that method already sets the address retrieved from the _edd_user_address metadata as the primary, so this query seems potentially redundant.
Additionally, I believe this step is only run as part of a CLI migration, not through the UI migration, so we need to evaluate if it should be added to the UI migration or if it should be removed from the CLI migration.
Additionally, the customer_addresses method should more properly be using the edd_maybe_add_customer_address method instead of edd_add_customer_address, as this migration runs after the orders have migrated and the order addresses have been added to the database. So when the customer address is added at this point, it's actually generally creating a duplicate address, unless the customer updated their address after their most recent order (and therefore the user meta record is not a duplicate of an address stored with an order).
UPDATE wp_edd_customer_addresses ca
SET ca.is_primary = 1
WHERE ca.id IN (
SELECT MAX(ca2.id)
FROM ( SELECT id, customer_id FROM wp_edd_customer_addresses WHERE type = 'billing' ) ca2
GROUP BY ca2.customer_id
)
There have been 2 users so far that I worked with that had this same query causing a lock on the database.
Another user has reported this query as being problematic and getting stuck. https://secure.helpscout.net/conversation/2015776214/2178547?folderId=5762562