Koha-clms/installer/data/mysql
Tomas Cohen Arazi 1938a0df43 Bug 14598: (QA followup) use deleted{items|biblioitems} during upgrade
If the 'statistics' table contains circulation information about items
that are no longer on the DB it will raise a warning. This patch
makes the updatedatabase.pl script use the deleteditems and deletedbiblioitems
tables to get information for those items on the statistics table.

To reproduce:
- 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);
+------------+-------+----------+
| itemnumber | itype | itemtype |
+------------+-------+----------+
|        732 | BK    | BK       |
|        731 | BK    | BK       |
+------------+-------+----------+
2 rows in set (0.00 sec)

- Delete the items, and some biblio too.
- Re-run the query
=> SUCCESS: Same results
- 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
=> SUCCESS: No warnings

Note: It is possible that on production sites, if the sysadmin is cleaning the
deleted{items|biblioitems|biblio} tables, there will be warnings. This is expected
as they need to know some data lacks information.

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Mason James <mtj@kohaaloha.com>
2016-12-12 14:54:11 +13:00
..
atomicupdate Bug 17518 - DBRev 16.05.05.001 2016-11-02 18:49:52 +00:00
de-DE Bug 16554: rewrite mandatory and sample data - de-DE 2016-09-15 16:59:44 +02:00
en Bug 17357: Replace WTHDRAWN with WITHDRAWN in installer files 2016-10-22 13:59:22 +02:00
es-ES Bug 17357: Replace WTHDRAWN with WITHDRAWN in installer files 2016-10-22 13:59:22 +02:00
fr-CA Bug 16554: Fix I18N sample files 2016-09-15 16:57:51 +02:00
fr-FR Bug 16554: Fix fr-FR sample files 2016-09-15 16:57:01 +02:00
it-IT Bug 16554: Fix encoding on it-IT file 2016-09-15 17:00:01 +02:00
mandatory Bug 17518: Displayed language name for Czech is wrong 2016-11-02 18:47:50 +00:00
nb-NO Bug 16554: More i18n changes - en, es, nb and pl files 2016-09-15 16:59:12 +02:00
pl-PL Bug 17357: Replace WTHDRAWN with WITHDRAWN in installer files 2016-10-22 13:59:22 +02:00
ru-RU Bug 17357: Replace WTHDRAWN with WITHDRAWN in installer files 2016-10-22 13:59:22 +02:00
uk-UA Bug 17357: Replace WTHDRAWN with WITHDRAWN in installer files 2016-10-22 13:59:22 +02:00
audio_alerts.sql Bug 11431: (QA followup) Make audio alerts sql top level 2015-11-04 12:33:53 -03:00
backfill_statistics.pl Bug 16011: $VERSION - Remove comments 2016-03-24 17:20:29 +00:00
fix_unclosed_nonaccruing_fines_bug17135.pl Bug 17135: [QA Follow-up] Changes as to reporting 2016-09-22 08:17:41 +02:00
kohastructure.sql Bug 16573: fix structure and sample data for MySQL 5.7 2016-08-05 07:12:36 +02:00
labels_upgrade.pl Bug 9978: Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:38 -03:00
patroncards_upgrade.pl Bug 9978: Replace license header with the correct license (GPLv3+) 2015-04-20 09:59:38 -03:00
sysprefs.sql Bug 14707 : Replace UsageStatsCountry syspref from free text to a dropdown list. 2016-09-30 11:06:38 +02:00
update22to30.pl Bug 11398: A typo occurred with occured 2014-01-02 15:12:48 +00:00
updatedatabase.pl Bug 14598: (QA followup) use deleted{items|biblioitems} during upgrade 2016-12-12 14:54:11 +13:00
userflags.sql Bug 13632: Populate user_flags and permissions tables in the web installer 2015-10-19 09:38:04 -03:00
userpermissions.sql Bug 7736: Support Ordering via Edifact EDI messages 2016-04-01 20:03:17 +00:00