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)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 15 Aug 2023 08:25:40 +0000 (11:25 +0300)
commit765d3d85b5b2b2e0711550b5b244d71967a2ee0c
treef0c6b6b9b72ba5226fc2a368694c701ee2f88734
parent39e6b100cb977f072e6f23a13625e986a31aab97
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>
installer/data/mysql/atomicupdate/bug_30451_do_not_delete_orders_with_subscription.pl [new file with mode: 0755]
installer/data/mysql/kohastructure.sql