From 19460605f720614ab4b0ee1c17730aca55136b74 Mon Sep 17 00:00:00 2001 From: Hayley Mapley Date: Tue, 20 Aug 2019 03:04:28 +0000 Subject: [PATCH] Bug 8367: (follow-up) Updates to DBIx class files Ran the update_dbix_class_files.pl script to regenerate the Koha/Schema/Result/ files again to match the database changes Making the atomicupdate file idempotent Sponsored-by: Brimbank Library, Australia Authored-by: Hayley Mapley and Alex Buckley --- Koha/Schema/Result/Issuingrule.pm | 11 +++++- Koha/Schema/Result/OldReserve.pm | 12 +++++- Koha/Schema/Result/Reserve.pm | 12 +++++- installer/data/mysql/atomicupdate/bug_8367.perl | 50 +++++++++++++++---------- 4 files changed, 59 insertions(+), 26 deletions(-) diff --git a/Koha/Schema/Result/Issuingrule.pm b/Koha/Schema/Result/Issuingrule.pm index ecc549e5a8a..c0af7eaa5ea 100644 --- a/Koha/Schema/Result/Issuingrule.pm +++ b/Koha/Schema/Result/Issuingrule.pm @@ -160,6 +160,11 @@ __PACKAGE__->table("issuingrules"); default_value: 0 is_nullable: 0 +=head2 holdspickupwait + + data_type: 'integer' + is_nullable: 1 + =head2 holds_per_record data_type: 'smallint' @@ -272,6 +277,8 @@ __PACKAGE__->add_columns( { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, "reservesallowed", { data_type => "smallint", default_value => 0, is_nullable => 0 }, + "holdspickupwait", + { data_type => "integer", is_nullable => 1 }, "holds_per_record", { data_type => "smallint", default_value => 1, is_nullable => 0 }, "holds_per_day", @@ -314,8 +321,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype"); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-05 20:49:11 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6bPX0BRWWQZrWFun3GP86Q +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-08-20 02:39:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nVZzow7RuzPASVF3rdxeZg sub koha_object_class { 'Koha::IssuingRule'; diff --git a/Koha/Schema/Result/OldReserve.pm b/Koha/Schema/Result/OldReserve.pm index de9fc6cb27d..d94a07c7ab4 100644 --- a/Koha/Schema/Result/OldReserve.pm +++ b/Koha/Schema/Result/OldReserve.pm @@ -130,6 +130,12 @@ __PACKAGE__->table("old_reserves"); datetime_undef_if_invalid: 1 is_nullable: 1 +=head2 lastpickupdate + + data_type: 'date' + datetime_undef_if_invalid: 1 + is_nullable: 1 + =head2 itemtype data_type: 'varchar' @@ -196,6 +202,8 @@ __PACKAGE__->add_columns( datetime_undef_if_invalid => 1, is_nullable => 1, }, + "lastpickupdate", + { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, "itemtype", { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, "item_level_hold", @@ -297,8 +305,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-06-17 07:24:39 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZgGAW7ODBby3hGNJ41eeMA +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-08-20 02:39:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CTozZnDtmr5SAU10tRbNUw sub koha_object_class { 'Koha::Old::Hold'; diff --git a/Koha/Schema/Result/Reserve.pm b/Koha/Schema/Result/Reserve.pm index 086b621f5fd..06ec5e10e34 100644 --- a/Koha/Schema/Result/Reserve.pm +++ b/Koha/Schema/Result/Reserve.pm @@ -134,6 +134,12 @@ __PACKAGE__->table("reserves"); datetime_undef_if_invalid: 1 is_nullable: 1 +=head2 lastpickupdate + + data_type: 'date' + datetime_undef_if_invalid: 1 + is_nullable: 1 + =head2 itemtype data_type: 'varchar' @@ -210,6 +216,8 @@ __PACKAGE__->add_columns( datetime_undef_if_invalid => 1, is_nullable => 1, }, + "lastpickupdate", + { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 }, "itemtype", { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 }, "item_level_hold", @@ -321,8 +329,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-06-17 07:24:39 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OMFqEWyKqFTcYj7vAFXy/g +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-08-20 02:39:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B9A9RCfZpr/rGs362rQ9RA __PACKAGE__->belongs_to( "item", diff --git a/installer/data/mysql/atomicupdate/bug_8367.perl b/installer/data/mysql/atomicupdate/bug_8367.perl index 59cad22cb97..845a26c1fab 100644 --- a/installer/data/mysql/atomicupdate/bug_8367.perl +++ b/installer/data/mysql/atomicupdate/bug_8367.perl @@ -1,21 +1,31 @@ -my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay -$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; }); -$dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; }); -# //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait -# //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules. -$dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; }); -$dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); -$dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); -my $sth = $dbh->prepare(q{ - UPDATE issuingrules SET holdspickupwait = ? -}); -$sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all! -##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay' -print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n"; -$sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; }); -$sth->execute( ); -my $dtdur = DateTime::Duration->new( days => 0 ); -while ( my $res = $sth->fetchrow_hashref ) { - C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB. +$DBversion = 'XXX'; #Replaced by RM +if( CheckVersion( $DBversion ) ) { + my $maxpickupdelay = C4::Context->preference('ReservesMaxPickUpDelay') || 0; #MaxPickupDelay + $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ReservesMaxPickUpDelay'; }); + $dbh->do(q{ DELETE FROM systempreferences WHERE variable='ExpireReservesOnHolidays'; }); + # //DELETE FROM systempreferences WHERE variable='ExpireReservesMaxPickUpDelay'; #This syspref is not needed and would be better suited to be calculated from the holdspickupwait + # //ExpireReservesMaxPickUpDelayCharge #This could be added as a column to the issuing rules. + unless( column_exists( 'issuingrules', 'holdspickupwait' ) ) { + $dbh->do(q{ ALTER TABLE issuingrules ADD COLUMN holdspickupwait INT(11) NULL default NULL AFTER reservesallowed; }); + } + unless( column_exists( 'reserves', 'lastpickupdate' ) ) { + $dbh->do(q{ ALTER TABLE reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); + } + unless( column_exists( 'old_reserves', 'lastpickupdate' ) ) { + $dbh->do(q{ ALTER TABLE old_reserves ADD COLUMN lastpickupdate DATE NULL default NULL AFTER suspend_until; }); + } + + my $sth = $dbh->prepare(q{ + UPDATE issuingrules SET holdspickupwait = ? + }); + $sth->execute( $maxpickupdelay ) if $maxpickupdelay; #Don't want to accidentally nullify all! + ##Populate the lastpickupdate-column from existing 'ReservesMaxPickUpDelay' + print "Populating the new lastpickupdate-column for all waiting holds. This might take a while.\n"; + $sth = $dbh->prepare(q{ SELECT * FROM reserves WHERE found = 'W'; }); + $sth->execute( ); + my $dtdur = DateTime::Duration->new( days => 0 ); + while ( my $res = $sth->fetchrow_hashref ) { + C4::Reserves::MoveWaitingdate( $res, $dtdur ); #We call MoveWaitingdate with a 0 duration to simply recalculate the lastpickupdate and store the new values to DB. + } + print "Upgrade to $DBversion done (Bug 8367: Add colum issuingrules.holdspickupwait and reserves.lastpickupdate. Populates introduced columns from the expiring ReservesMaxPickUpDelay. Deletes the ReservesMaxPickUpDelay and ExpireReservesOnHolidays -sysprefs)\n"; } -print "Upgrade to $DBversion done (8367: Add colum issuingrules.holdspickupwait and reserves.lastpickupdate. Populates introduced columns from the expiring ReservesMaxPickUpDelay. Deletes the ReservesMaxPickUpDelay and ExpireReservesOnHolidays -sysprefs)\n";>>>>>>> Bug 8367: Template fixes + fixes to C4/Reserves.pm and Koha/Hold.pm -- 2.11.0