Bug 21901: Add FK on subscription and serial tables
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 11 Dec 2019 07:29:27 +0000 (08:29 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Fri, 17 Apr 2020 08:39:00 +0000 (09:39 +0100)
commit9287585f3823b9375d5bdbbc7128e0141dafb4f6
tree6e7f63fd8a05a492a9ce966acc68214429b77375
parent2484fb6ac508e7709de9473694512ce09b12aff9
Bug 21901: Add FK on subscription and serial tables

In order to improve performance in the serial modules and add DB constraints,
this patch is going to add missing foreign key on the following columns:
 * serial.biblionumber
 * serial.subscription
 * subscriptionhistory.biblionumber
 * subscriptionhistory.subscriptionid
 * subscription.biblionumber

Once done, some code can be removed from the Del* subroutines, as the ON
CASCASE clause will make the RDBMS handles the deletions.

Test plan:
0/ It would be useful to test the update DB entry on a big and old
production DB, to make sure the constraints will be added correctly.
We could remove the entries before creating the constraints, but it can
be unecessary
1/ Make sure you can recreate a fresh install with the kohastructure.sql
from this patch
2/ Make sure you can upgrade from a master install
3/ Create a subscription, serial, etc. and delete the biblio
=> The subscription/serials should have been deleted from the DB
4/ Create a subscription, serial, etc. and delete the subscription
=> The serials should have been deleted from the DB

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
C4/Biblio.pm
C4/Serials.pm
installer/data/mysql/atomicupdate/bug_21901.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql
t/db_dependent/Biblio.t