craftcms / digital-products

Sell digital products with Craft Commerce.
https://plugins.craftcms.com/digital-products
MIT License
18 stars 9 forks source link

Garbage collection fails with integrity constraint violation #75

Closed rob-c-baker closed 2 years ago

rob-c-baker commented 2 years ago

Description

Running Craft's garbage collection (i.e. php craft gc) a database exception is thrown as follows:

Error: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails ([database].`digitalproducts_licenses`, CONSTRAINT `digitalproducts_licenses_productId_fk` FOREIGN KEY (`productId`) REFERENCES `digitalproducts_products` (`id`))
The SQL being executed was: DELETE FROM `elements` WHERE NOT (`dateDeleted` IS NULL)

Steps to reproduce

  1. Have a Craft & Commerce install with some digital product licenses present
  2. Run php craft gc

Additional info

This was encountered immediately prior to upgrading Craft & Commerce to v4 on the advice of @angrybrad via support, attempting to work around another non-relevant issue.

pdaleramirez commented 2 years ago

@rob-baker-ar This is a known issue. We are thinking of ways on how to deal with this bug.

rob-c-baker commented 2 years ago

@lukeholder Looks like you added a fix for this, penned for 3.1.0 - do you know when that release will happen?

lukeholder commented 2 years ago

This has been fixed for the next release. The migration will restore the soft deleted digital products but set them to disabled. All licenses need to be deleted before a digital product can be soft deleted.