]> git.koha-community.org Git - koha.git/commit
Bug 37419: Update FK constraint on record sources to avoid data loss
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 29 Jul 2024 11:12:56 +0000 (08:12 -0300)
committerLucas Gass <lucas@bywatersolutions.com>
Thu, 29 Aug 2024 17:25:35 +0000 (17:25 +0000)
commit57046b92a0ce9fa14320ca830f23e78ba7f10bc1
treec6501ea854ecb8aaef48eed90f7d208789632c03
parentb603bd91b363bcd323e4a79c837ac24361614b85
Bug 37419: Update FK constraint on record sources to avoid data loss

Without this patch, deleting a record source will delete the associated
biblio_metadata rows, which is a severe data loss.

This patch makes the constraint restrict this action.

To test:
1. Add a record source
2. Set the record source to some records
   $ koha-mysql kohadev
   > UPDATE biblio_metadata SET record_source_id='your source id' WHERE
biblionumber=1;
3. Delete the record source
=> FAIL: Record metadata deleted
4. Apply this patch
5, Run:
   $ ktd --shell
  k$ updatedatabase
=> SUCCESS: DB update goes well
6. Repeat 1~3 with another record
=> SUCCESS: Source cannot be deleted if there are linked records

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Janusz Kaczmarek <januszop@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8754458775da37acfc2513cc0c1b2523740fe79b)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
installer/data/mysql/atomicupdate/bug_37419.pl [new file with mode: 0755]
installer/data/mysql/kohastructure.sql