Bug 30451: Update FK constraint on aqorders.subscriptionid
authorKatrin Fischer <katrin.fischer@bsz-bw.de>
Fri, 21 Jul 2023 14:39:07 +0000 (14:39 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 17 Aug 2023 18:45:43 +0000 (08:45 -1000)
commit43c55cad8a4a14fccc6112ca327603c07068d0c1
treeff5c9b12ec9da48ea4c53750fe3b2b98c1fa4dce
parentbdfe5b3cdebc444c7327280ffcf0e44121d35fca
Bug 30451: Update FK constraint on aqorders.subscriptionid

This updates the FK constrant from ON DELETE CASCADE to ON DELETE
SET NULL. This means that if a subscription linked to an order is
deleted, we no longer will also delete the order, but we will just
set subscrptinid in the order to NULL. This will avoid data loss
that can cause the budgets/funds not to add up anymore with the
real espenses of the library.

To test:

Preparation:
* Create 2 subscriptions on different records
* Create a new basket
* Use the "order from subscription" functionality to create order
  lines for both of your subscriptions
* Close basket

Without patch:
* Delete the first subscription
* Verify the order line for this subscription is gone from your basket

Apply patch:
* Run database update and restart_all
* Delete the second subscription
* Verify the order line now remained in the basket

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
JD amended patch: perl tidy

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 765d3d85b5b2b2e0711550b5b244d71967a2ee0c)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
installer/data/mysql/atomicupdate/bug_30451_do_not_delete_orders_with_subscription.pl [new file with mode: 0755]
installer/data/mysql/kohastructure.sql