Cleanup database from outdated licenses which will never be re-used

Created on 29 January 2018, over 7 years ago
Updated 19 August 2025, 5 days ago

On a DCL project users purchase frequently cancelled service products. The current logic is when an order is cancelled then all the licenses associated with the order's line items get revoked. When users need the same services again then new orders are created, so new licenses are created and the revoked ones are never re-used.

Unfortunately, deleting the licenses trigger the commerce_license_delete_references function, which deletes all the associated line items and that in its turn empties and so deletes some orders. And unlike the licenses, which end-users never see, the orders are needed for historical purposes - PDF invoices are generated from orders, which should be always available.

Ideally, when licenses are deleted then only line-items of the relevant recurring orders should be deleted and all the other types of orders (with checked out/invoiced/paid status) should be kept intact. So I would suggest re-factor the above function and if that's not possible because of existence of massive real-time use-cases (which I can't really fancy) which need the current behavior, then I wonder what is the best way to keep database clean of outdated licenses which will never be of use again? Should I get my hands dirty by removing them with direct DB query? Might some problems pop up in that case?

πŸ’¬ Support request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024