Bug 23265

Summary: Update to DB revision 16.12.00.032 fails: Unknown column 'me.item_level_hold'
Product: Koha Reporter: Mirko Tietgen <mirko>
Component: DatabaseAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: blocker    
Priority: P5 - low CC: cmurdock, fridolin.somers, jonathan.druart, katrin.fischer, lucas, m.de.rooy, martin.renvoize, victor
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=9834
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00,19.05.04, 18.11.10
Bug Depends on: 12063    
Bug Blocks: 19789, 23809    
Attachments: Bug 23265: (bug 12063 follow-up) Remove Koha::Holds from updatedatabase
Bug 23265: (bug 12063 follow-up) Remove Koha::Holds from updatedatabase
Bug 23265: (bug 12063 follow-up) Remove Koha::Holds from updatedatabase

Description Mirko Tietgen 2019-07-04 10:13:37 UTC
When creating an instance from an older DB and running koha-upgrade-schema, the following error occurs.

>[…]
>Upgrade to 16.12.00.030 done (Bug 16344 - Add a circ rule to limit the auto renewals given a specific date)
>Upgrade to 16.12.00.031 done (Bug 15108: OAI-PMH provider improvements)
>DBD::mysql::st execute failed: Unknown column 'me.item_level_hold' in 'field list' [for Statement "SELECT `me`.`reserve_id`, `me`.`borrowernumber`, `me`.`reservedate`, `me`.`biblionumber`, `me`.`branchcode`, `me`.`notificationdate`, `me`.`reminderdate`, `me`.`cancellationdate`, `me`.`reservenotes`, `me`.`priority`, `me`.`found`, `me`.`timestamp`, `me`.`itemnumber`, `me`.`waitingdate`, `me`.`expirationdate`, `me`.`lowestPriority`, `me`.`suspend`, `me`.`suspend_until`, `me`.`itemtype`, `me`.`item_level_hold` FROM `reserves` `me` WHERE ( ( `found` = ? AND `priority` = ? ) )" with ParamValues: 0='W', 1=0] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1836.
>DBIx::Class::Storage::DBI::_dbh_execute(): Unknown column 'me.item_level_hold' in 'field list' at /usr/share/koha/lib/Koha/Objects.pm line 209
Comment 1 Katrin Fischer 2019-07-05 06:07:05 UTC
Please link the bugs in cases like this - I didn't find this one :)
Closing my duplicate.
Comment 2 Katrin Fischer 2019-07-05 06:07:32 UTC
*** Bug 23267 has been marked as a duplicate of this bug. ***
Comment 3 Mirko Tietgen 2019-07-05 06:12:34 UTC
(In reply to Katrin Fischer from comment #1)
> Please link the bugs in cases like this - I didn't find this one :)
> Closing my duplicate.

I did, but as "See also" as I was not 100% sure 9834 is to blame. ;)
Comment 4 Katrin Fischer 2019-07-05 06:13:16 UTC
(In reply to Mirko Tietgen from comment #3)
> (In reply to Katrin Fischer from comment #1)
> > Please link the bugs in cases like this - I didn't find this one :)
> > Closing my duplicate.
> 
> I did, but as "See also" as I was not 100% sure 9834 is to blame. ;)

Might just be my morning me is not very awake yet :)
Comment 5 Jonathan Druart 2019-08-05 18:30:38 UTC
It comes from bug 12063 that is using Koha:: modules in updatedatabase.pl
Comment 6 Jonathan Druart 2019-08-06 14:11:42 UTC
Created attachment 92029 [details] [review]
Bug 23265: (bug 12063 follow-up) Remove Koha::Holds from updatedatabase

Test plan:
Have a DB that fail the 16.12.00.032 update, then apply this patch and
verify the expiration dates

RM: Please inforce this rule, no use of Koha:: in updatedatabase!
Comment 7 Victor Grousset/tuxayo 2019-09-03 15:31:36 UTC
Created attachment 92576 [details] [review]
Bug 23265: (bug 12063 follow-up) Remove Koha::Holds from updatedatabase

Test plan:
Have a DB that fail the 16.12.00.032 update, then apply this patch and
verify the expiration dates

RM: Please inforce this rule, no use of Koha:: in updatedatabase!

Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>
Comment 8 Victor Grousset/tuxayo 2019-09-03 15:32:15 UTC
Thanks, I just stumbled on this issue :)
Comment 9 Marcel de Rooy 2019-09-06 05:42:55 UTC
Created attachment 92612 [details] [review]
Bug 23265: (bug 12063 follow-up) Remove Koha::Holds from updatedatabase

Test plan:
Have a DB that fail the 16.12.00.032 update, then apply this patch and
verify the expiration dates

RM: Please inforce this rule, no use of Koha:: in updatedatabase!

Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 10 Martin Renvoize 2019-09-06 12:12:26 UTC
Nice work!

Pushed to master for 19.11.00
Comment 11 Fridolin Somers 2019-09-09 06:55:22 UTC
Pushed to 19.05.x for 19.05.04
Comment 12 Lucas Gass 2019-09-24 20:23:41 UTC
backported to 18.11.x for 18.11.10
Comment 13 Cindy Murdock Ames 2019-11-13 17:59:34 UTC
My apologies if this doesn't belong here, but I seem to be having an issue relating to this same section of code.  I'm upgrading from a dev install of 3.22, slightly customized so maybe this is unique to me.  I've imported the database into a fresh install on 19.05.04 using mariadb 10.1 on ubuntu 18.04, and I get this error and the database update halts when running koha-upgrade-schema:

Upgrade to 16.12.00.031 done (Bug 15108: OAI-PMH provider improvements)
Not a HASH reference at /usr/share/koha/intranet/cgi-bin/installer/data/mysql/updatedatabase.pl line 14371.

My reserves table doesn't contain anything in expirationdate other than NULL.
Comment 14 Cindy Murdock Ames 2019-11-13 19:10:27 UTC
Nevermind, I found https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=23809 which is the same issue I'm having.   I applied that patch and my problem is resolved. 

Sorry for the noise!