From e39b9684d5cd0ce15a3d1f07d7691b832309287b Mon Sep 17 00:00:00 2001 From: David Cook Date: Thu, 29 Oct 2020 05:20:53 +0000 Subject: [PATCH] Bug 26853: Harmonize import_biblios with biblio and biblioitems This patch harmonizes the column datatypes of import_biblios with biblio and biblioitems to prevent database errors which cause staged MARC uploads to sometimes fail to update 100% correctly. To test: 1. Go to http://localhost:8081/cgi-bin/koha/tools/stage-marc-import.pl 2. Upload a file with MARC records with titles longer than 128 characters long 3. Click "Stage for import" 4. Monitor /var/log/koha/kohadev/intranet-error.log for database errors 5. Note that there are no database errors Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- .../001-26853-update-import_biblios.perl | 15 +++++++++++++++ installer/data/mysql/kohastructure.sql | 12 ++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/001-26853-update-import_biblios.perl diff --git a/installer/data/mysql/atomicupdate/001-26853-update-import_biblios.perl b/installer/data/mysql/atomicupdate/001-26853-update-import_biblios.perl new file mode 100644 index 0000000000..b76413c445 --- /dev/null +++ b/installer/data/mysql/atomicupdate/001-26853-update-import_biblios.perl @@ -0,0 +1,15 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + $dbh->do("DROP INDEX title ON import_biblios"); + $dbh->do("DROP INDEX isbn ON import_biblios"); + $dbh->do("ALTER TABLE import_biblios MODIFY title LONGTEXT"); + $dbh->do("ALTER TABLE import_biblios MODIFY author LONGTEXT"); + $dbh->do("ALTER TABLE import_biblios MODIFY isbn LONGTEXT"); + $dbh->do("ALTER TABLE import_biblios MODIFY issn LONGTEXT"); + $dbh->do("CREATE INDEX title ON import_biblios (title(191));"); + $dbh->do("CREATE INDEX isbn ON import_biblios (isbn(191));"); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 26853, "Update import_biblios columns and indexes"); +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 0ed6bc202e..5418258f08 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -792,16 +792,16 @@ CREATE TABLE `import_biblios` ( `matched_biblionumber` int(11) default NULL, `control_number` varchar(25) default NULL, `original_source` varchar(25) default NULL, - `title` varchar(128) default NULL, - `author` varchar(80) default NULL, - `isbn` varchar(30) default NULL, - `issn` varchar(9) default NULL, + `title` LONGTEXT default NULL, + `author` LONGTEXT default NULL, + `isbn` LONGTEXT default NULL, + `issn` LONGTEXT default NULL, `has_items` tinyint(1) NOT NULL default 0, CONSTRAINT `import_biblios_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE, KEY `matched_biblionumber` (`matched_biblionumber`), - KEY `title` (`title`), - KEY `isbn` (`isbn`) + KEY `title` (`title`(191)), + KEY `isbn` (`isbn`(191)) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- 2.39.5