Bug 26025 - Data loss issue during Schema database upgrade from 16.11
Summary: Data loss issue during Schema database upgrade from 16.11
Status: CLOSED WONTFIX
Alias: None
Product: Koha
Classification: Unclassified
Component: Installation and upgrade (command-line installer) (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-20 10:06 UTC by Vinod
Modified: 2024-07-04 20:37 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vinod 2020-07-20 10:06:53 UTC
Hi

While trying to run database upgrade command from Koha 16.11 to 20.05 it gives following error:

Upgrade to 16.12.00.003 done (Bug 17486 - Remove 'Mozilla Persona' as an authentication method)
DBD::mysql::db do failed: Cannot add or update a child row: a foreign key constraint fails (`koha_library`.`deletedbiblio_metadata`, CONSTRAINT `deletedbiblio_metadata_fk_1` FOREIGN KEY (`biblionumber`) REFERENCES `deletedbiblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE) [for Statement "
        INSERT INTO deletedbiblio_metadata ( biblionumber, format, marcflavour, metadata ) SELECT biblionumber, 'marcxml', 'CHANGEME', marcxml FROM deletedbiblioitems;
    "] at /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl line 13816.


Above seems to be data loss under deletedbiblioitem etc. as per discussion over Koha mailing list?
Comment 1 Jonathan Druart 2020-07-22 09:50:31 UTC
Hi Vinod,

This is a quite old update DB version, and I am not sure it makes sense to fix it as nobody else reported the problem before.

To handle this you could:
1. Restore a previous version of the DB
2. Fix the id collision in deletedbiblioitems
This wiki page will help you to catch the problematic entries:
https://wiki.koha-community.org/wiki/DBMS_auto_increment_fix#Is_your_data_corrupted.3F
Basically you need find the duplicate ID in deletedbiblio[items] tables, like:

select count(*) as c, biblionumber from deletedbiblio group by biblionumber having c > 1;

The easier is to remove the duplicated ID, but you may delete important data.
If you want to keep the data you should modify the ID (this can be tricky, depending on the other data you have in biblio[items])

3. Execute the updatedatabase script
Comment 2 Katrin Fischer 2023-09-16 16:28:34 UTC
(In reply to Jonathan Druart from comment #1)
> Hi Vinod,
> 
> This is a quite old update DB version, and I am not sure it makes sense to
> fix it as nobody else reported the problem before.

It's another 3 years later. I am closing WONTFIX.