Bug 26025

Summary: Data loss issue during Schema database upgrade from 16.11
Product: Koha Reporter: Vinod <mishravk79>
Component: Installation and upgrade (command-line installer)Assignee: Bugs List <koha-bugs>
Status: CLOSED WONTFIX QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: amit.gupta, amitddng135, jonathan.druart
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:

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.