]> 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)
committerKatrin Fischer <katrin.fischer@bsz-bw.de>
Thu, 1 Aug 2024 16:22:29 +0000 (18:22 +0200)
commit8754458775da37acfc2513cc0c1b2523740fe79b
tree3cfa890c1a24b8738e809cd16d1d4323d0560b2b
parentf4d248f076ef7368535beead9689acf4ad98d5f3
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>
installer/data/mysql/atomicupdate/bug_37419.pl [new file with mode: 0755]
installer/data/mysql/kohastructure.sql