@@ -, +, @@ during upgrade - Have your sample DB contain some circulation data on the statistics table - Make sure some of them have NULL itemtype: +UPDATE statistics SET itemtype = NULL WHERE type='return'; - Check the upgrade query catches them: +SELECT s.itemnumber, i.itype, b.itemtype FROM ( SELECT DISTINCT itemnumber FROM statistics WHERE ( type = "return" OR type = "localuse" ) AND itemtype IS NULL ) s LEFT JOIN ( SELECT itemnumber,biblionumber, itype FROM items UNION SELECT itemnumber,biblionumber, itype FROM deleteditems ) i ON (s.itemnumber=i.itemnumber) LEFT JOIN ( SELECT biblionumber, itemtype FROM biblioitems UNION SELECT biblionumber, itemtype FROM deletedbiblioitems ) b ON (i.biblionumber=b.biblionumber); +------------+-------+----------+ +------------+-------+----------+ +------------+-------+----------+ - Delete the items, and some biblio too. - Re-run the query - Go reset to NULL the itemtypes +UPDATE statistics SET itemtype = NULL WHERE type='return'; - Run the updatedatabase.pl script: $ sudo koha-shell koahdev ; cd kohaclone $ perl installer/data/mysql/updatedatabase.pl --- installer/data/mysql/updatedatabase.pl | 35 ++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -12210,18 +12210,29 @@ $DBversion = "3.23.00.XXX"; if ( CheckVersion($DBversion) ) { $sth = $dbh->prepare(q{ - SELECT s.itemnumber, i.itype, b.itemtype FROM - ( SELECT DISTINCT itemnumber - FROM statistics - WHERE ( type = "return" OR type = "localuse" ) AND itemtype IS NULL ) s - LEFT JOIN - ( SELECT itemnumber,biblionumber, itype - FROM items ) i - ON (s.itemnumber=i.itemnumber) - LEFT JOIN - ( SELECT biblionumber, itemtype - FROM biblioitems ) b - ON (i.biblionumber=b.biblionumber) + SELECT s.itemnumber, i.itype, b.itemtype + FROM + ( SELECT DISTINCT itemnumber + FROM statistics + WHERE ( type = "return" OR type = "localuse" ) AND + itemtype IS NULL + ) s + LEFT JOIN + ( SELECT itemnumber,biblionumber, itype + FROM items + UNION + SELECT itemnumber,biblionumber, itype + FROM deleteditems + ) i + ON (s.itemnumber=i.itemnumber) + LEFT JOIN + ( SELECT biblionumber, itemtype + FROM biblioitems + UNION + SELECT biblionumber, itemtype + FROM deletedbiblioitems + ) b + ON (i.biblionumber=b.biblionumber); }); $sth->execute(); --