Bug 13881: DBRev 19.12.00.054
[koha-ffzg.git] / installer / data / mysql / updatedatabase.pl
index 62b447c..0f51b28 100755 (executable)
@@ -20228,21 +20228,18 @@ if( CheckVersion( $DBversion ) ) {
 
 $DBversion = '19.11.00.000';
 if( CheckVersion( $DBversion ) ) {
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (19.11.00 release)\n";
+    NewVersion( $DBversion, undef, '19.11.00 release' );
 }
 
 $DBversion = '19.12.00.000';
 if( CheckVersion( $DBversion ) ) {
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Dobbie is a free elf...)\n";
+    NewVersion( $DBversion, undef, 'Dobbie is a free elf...' );
 }
 
 $DBversion = '19.12.00.001';
 if( CheckVersion( $DBversion ) ) {
     $dbh->do( "UPDATE marc_subfield_structure SET kohafield = NULL WHERE kohafield = 'bibliosubject.subject';" );
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 17831 - Remove non-existing bibliosubject.subject from frameworks)\n";
+    NewVersion( $DBversion, 17831, 'Remove non-existing bibliosubject.subject from frameworks' );
 }
 
 $DBversion = '19.12.00.002';
@@ -20254,8 +20251,7 @@ if( CheckVersion( $DBversion ) ) {
         WHERE variable = 'AllowItemsOnHoldCheckout'
     });
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 23233 - Rename AllowItemsOnHoldCheckout syspref)\n";
+    NewVersion( $DBversion, 23233, 'Rename AllowItemsOnHoldCheckout syspref' );
 }
 
 $DBversion = '19.12.00.003';
@@ -20265,9 +20261,7 @@ if( CheckVersion( $DBversion ) ) {
         $dbh->do( "ALTER TABLE library_groups ADD COLUMN ft_local_hold_group tinyint(1) NOT NULL DEFAULT 0 AFTER ft_search_groups_staff" );
     }
 
-    # Always end with this (adjust the bug info)
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 22284 - Add ft_local_hold_group column to library_groups)\n";
+    NewVersion( $DBversion, 22284, 'Add ft_local_hold_group column to library_groups' );
 }
 
 $DBversion = '19.12.00.004';
@@ -20297,19 +20291,14 @@ if ( CheckVersion($DBversion) ) {
         (10, 'payout', 'Perform account payout action')
     });
 
-    SetVersion($DBversion);
-    print "Upgrade to $DBversion done (Bug 24080 - Add PAYOUT account_debit_type)\n";
-    print "Upgrade to $DBversion done (Bug 24080 - Add PAYOUT account_offset_type)\n";
-    print "Upgrade to $DBversion done (Bug 24080 - Add accounts payout permission)\n";
+    NewVersion( $DBversion, 24080, ['Add PAYOUT account_debit_type', 'Add PAYOUT account_offset_type', 'Add accounts payout permission'] );
 }
 
 $DBversion = '19.12.00.005';
 if( CheckVersion( $DBversion ) ) {
     $dbh->do( "ALTER TABLE action_logs MODIFY COLUMN `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP" );
 
-    # Always end with this (adjust the bug info)
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24329 - Do not update action_log.timestamp)\n";
+    NewVersion( $DBversion, 24329, 'Do not update action_log.timestamp' );
 }
 
 $DBversion = '19.12.00.006';
@@ -20319,8 +20308,7 @@ if( CheckVersion( $DBversion ) ) {
         WHERE relationship = ""
     |);
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24263 - Replace relationship with NULL when empty string)\n";
+    NewVersion( $DBversion, 24263, 'Replace relationship with NULL when empty string' );
 }
 
 $DBversion = '19.12.00.007';
@@ -20344,10 +20332,7 @@ if ( CheckVersion($DBversion) ) {
         (10, 'refund', 'Perform account refund action')
     });
 
-    SetVersion($DBversion);
-    print "Upgrade to $DBversion done (Bug 23442 - Add REFUND to account_credit_types)\n";
-    print "Upgrade to $DBversion done (Bug 23442 - Add REFUND to account_offset_types)\n";
-    print "Upgrade to $DBversion done (Bug 23442 - Add accounts refund permission)\n";
+    NewVersion( $DBversion, 23442, ['Add REFUND to account_credit_types', 'Add REFUND to account_offset_types', 'Add accounts refund permission'] );
 }
 
 $DBversion = '19.12.00.008';
@@ -20356,8 +20341,7 @@ if( CheckVersion( $DBversion ) ) {
     $dbh->do( 'UPDATE systempreferences SET value = REPLACE(value, "http://www.bookfinder.com", "https://www.bookfinder.com") WHERE variable = "OPACSearchForTitleIn"' );
     $dbh->do( 'UPDATE systempreferences SET value = REPLACE(value, "https://openlibrary.org/search/?", "https://openlibrary.org/search?") WHERE variable = "OPACSearchForTitleIn"' );
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24206 - Update OpacSearchForTitleIn system preference)\n";
+    NewVersion( $DBversion, 24206, 'Update OpacSearchForTitleIn system preference' );
 }
 
 $DBversion = '19.12.00.009';
@@ -20479,10 +20463,7 @@ INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`,
         (25, 'takepayment', 'Access the point of sale page and take payments')
     });
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 23354 - Add 'Purchase' account offset type)\n";
-    print "Upgrade to $DBversion done (Bug 23354 - Add 'RECEIPT' notice for Point of Sale)\n";
-    print "Upgrade to $DBversion done (Bug 23354 - Add point of sale permissions)\n";
+    NewVersion( $DBversion, 23354, [q|Add 'Purchase' account offset type|, q|Add 'RECEIPT' notice for Point of Sale|, q|Add point of sale permissions|] );
 }
 
 $DBversion = '19.12.00.010';
@@ -20511,8 +20492,7 @@ if( CheckVersion( $DBversion ) ) {
         }
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 21520 - Add rule_order and rule_operator fields to oai_sets_mappings table)\n";
+    NewVersion( $DBversion, 21520, 'Add rule_order and rule_operator fields to oai_sets_mappings table' );
 }
 
 $DBversion = '19.12.00.011';
@@ -20543,8 +20523,7 @@ if( CheckVersion( $DBversion ) ) {
         |);
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24289 - Adding foreign keys on *_holidays.branchcode tables)\n";
+    NewVersion( $DBversion, 24289, 'Adding foreign keys on *_holidays.branchcode tables' );
 }
 
 $DBversion = '19.12.00.012';
@@ -20559,8 +20538,7 @@ if( CheckVersion( $DBversion ) ) {
           `code` = 'manage_cash_registers'
     });
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24481 - Move permission to correct module_bit)\n";
+    NewVersion( $DBversion, 24481, 'Move permission to correct module_bit' );
 }
 
 $DBversion = '19.12.00.013';
@@ -20572,8 +20550,7 @@ if( CheckVersion( $DBversion ) ) {
           ('EnablePointOfSale','0',NULL,'Enable the point of sale feature to allow anonymous transactions with the accounting system. (Requires UseCashRegisters)','YesNo')
     });
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24478 - Add `EnablePointOfSale` system preference to allow disabling the point of sale feature)\n";
+    NewVersion( $DBversion, 24478, 'Add `EnablePointOfSale` system preference to allow disabling the point of sale feature)' );
 }
 
 $DBversion = '19.12.00.014';
@@ -20590,8 +20567,7 @@ if( CheckVersion( $DBversion ) ) {
         );
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24287 - Add 'reason' field to transfers table)\n";
+    NewVersion( $DBversion, 24287, q|Add 'reason' field to transfers table| );
 }
 
 $DBversion = '19.12.00.015';
@@ -20636,8 +20612,7 @@ if( CheckVersion( $DBversion ) ) {
           }
     );
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24296 - Update stockrotation to use 'reason' field in transfers table)\n";
+    NewVersion( $DBversion, 24296, q|Update stockrotation to use 'reason' field in transfers table| );
 }
 
 $DBversion = '19.12.00.016';
@@ -20656,8 +20631,7 @@ if( CheckVersion( $DBversion ) ) {
         UPDATE borrowers SET flags = flags + (1<<12) WHERE flags & (1 << 11)
     });
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 22868 - Move suggestions_manage subpermission out of acquisition permission)\n";
+    NewVersion( $DBversion, 22868, 'Move suggestions_manage subpermission out of acquisition permission' );
 }
 
 $DBversion = '19.12.00.017';
@@ -20678,8 +20652,7 @@ if( CheckVersion( $DBversion ) ) {
         |);
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 21674 - Add unique key (parent_id, branchcode) to library_group)\n";
+    NewVersion( $DBversion, 21674, 'Add unique key (parent_id, branchcode) to library_group' );
 }
 
 $DBversion = '19.12.00.018';
@@ -20727,8 +20700,7 @@ if( CheckVersion( $DBversion ) ) {
         $dbh->do("DROP TABLE issuingrules");
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 18936: Convert issuingrules fields to circulation_rules)\n";
+    NewVersion( $DBversion, 18936, 'Convert issuingrules fields to circulation_rules' );
 }
 
 $DBversion = '19.12.00.019';
@@ -20741,8 +20713,7 @@ if( CheckVersion( $DBversion ) ) {
         $dbh->do("UPDATE message_queue SET updated_on=time_queued");
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 23673 - modify time_queued and add updated_on to message_queue)\n";
+    NewVersion( $DBversion, 23673, 'modify time_queued and add updated_on to message_queue' );
 }
 
 $DBversion = '19.12.00.020';
@@ -20753,8 +20724,8 @@ if ( CheckVersion($DBversion) ) {
     if ( !column_exists( 'marc_tag_structure', 'important') ){
         $dbh->do("ALTER TABLE marc_tag_structure ADD COLUMN important TINYINT(4) NOT NULL DEFAULT 0  AFTER mandatory");
     }
-    SetVersion($DBversion);
-    print "Upgrade to $DBversion done (Bug 8643 - Add important constraint to marc subfields)\n";
+
+    NewVersion( $DBversion, 8643, 'Add important constraint to marc subfields' );
 }
 
 $DBversion = '19.12.00.021';
@@ -20803,8 +20774,7 @@ if( CheckVersion( $DBversion ) ) {
           ( 'Lost Item Found' )
     });
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24592 - Update LOST_RETURN to LOST_FOUND)\n";
+    NewVersion( $DBversion, 24592, 'Update LOST_RETURN to LOST_FOUND');
 }
 
 $DBversion = '19.12.00.022';
@@ -20812,16 +20782,14 @@ if( CheckVersion( $DBversion ) ) {
     $dbh->do( "ALTER TABLE items MODIFY COLUMN uri MEDIUMTEXT" );
     $dbh->do( "ALTER TABLE deleteditems MODIFY COLUMN uri MEDIUMTEXT" );
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 20882 - items.uri to MEDIUMTEXT)\n";
+    NewVersion( $DBversion, 20882, 'items.uri to MEDIUMTEXT');
 }
 
 $DBversion = '19.12.00.023';
 if( CheckVersion( $DBversion ) ) {
     $dbh->do( "ALTER TABLE quotes MODIFY timestamp datetime NULL" );
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24640 - Allow quotes.timestamp to be NULL)\n";
+    NewVersion( $DBversion, 24640, 'Allow quotes.timestamp to be NULL');
 }
 
 $DBversion = '19.12.00.024';
@@ -20835,8 +20803,8 @@ if( CheckVersion( $DBversion ) ) {
         explanation = "Choose the fines mode, 'off' (do not accrue fines) or 'production' (accrue overdue fines).  Requires accruefines cronjob or CalculateFinesOnReturn system preference."
         WHERE variable = 'finesMode'
     });
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 21633  - Remove finesMode 'test')\n";
+
+    NewVersion( $DBversion, 21633, 'Remove finesMode "test"');
 }
 
 $DBversion = '19.12.00.025';
@@ -20845,8 +20813,8 @@ if( CheckVersion( $DBversion ) ) {
         INSERT IGNORE INTO `systempreferences` (variable,value,options,explanation,type)
         VALUES ('DumpSearchQueryTemplate',0,'','Add the search query being passed to the search engine into the template for debugging','YesNo')
     });
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24103 - add DumpSearchQueryTemplate syspref)\n";
+
+    NewVersion( $DBversion, 24103, 'add DumpSearchQueryTemplate syspref');
 }
 
 $DBversion = '19.12.00.026';
@@ -20855,8 +20823,7 @@ if( CheckVersion( $DBversion ) ) {
         $dbh->do( "ALTER TABLE z3950servers ADD COLUMN attributes VARCHAR(255) after add_xslt" );
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 11297 - Add support for custom PQF attributes for Z39.50 server searches)\n";
+    NewVersion( $DBversion, 11297, 'Add support for custom PQF attributes for Z39.50 server searches');
 }
 
 $DBversion = '19.12.00.027';
@@ -20898,9 +20865,7 @@ if( CheckVersion( $DBversion ) ) {
         debit_type_code IS NOT NULL
     });
 
-    # Always end with this (adjust the bug info)
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24532 - Fix pathological cases of negative debits)\n";
+    NewVersion( $DBversion, 24532, 'Fix pathological cases of negative debits');
 }
 
 $DBversion = '19.12.00.028';
@@ -20910,8 +20875,8 @@ if( CheckVersion( $DBversion ) ) {
         VALUES
         ('OpacBrowseSearch', '0',NULL, "Elasticsearch only: add a page allowing users to 'browse' all items in the collection",'YesNo')
     });
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 14567: Add OpacBrowseSearch syspref)\n";
+
+    NewVersion( $DBversion, 14567, 'Add OpacBrowseSearch syspref');
 }
 
 $DBversion = '19.12.00.029';
@@ -20920,8 +20885,7 @@ if( CheckVersion( $DBversion ) ) {
         $dbh->do('ALTER TABLE account_credit_types ADD COLUMN archived tinyint(1) NOT NULL DEFAULT 0 AFTER is_system');
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 17702 - Add column account_credit_types.archived)\n";
+    NewVersion( $DBversion, 17702, 'Add column account_credit_types.archived');
 }
 
 $DBversion = '19.12.00.030';
@@ -20942,17 +20906,20 @@ if( CheckVersion( $DBversion ) ) {
     my ($opacheader) = $dbh->selectrow_array( q|
         SELECT value FROM systempreferences WHERE variable='opacheader';
     |);
+
+    my @detail;
     if( $opacheader ){
         foreach my $lang ( @langs ) {
-            print "Inserting opacheader contents into $lang news item...\n";
             # If there is a value in the opacheader preference, insert it into opac_news
             $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "opacheader_$langs[0]", $opacheader);
+            push @detail, "Inserted opacheader contents into $lang news item...\n";
         }
     }
     # Remove the opacheader system preference
     $dbh->do("DELETE FROM systempreferences WHERE variable='opacheader'");
-    SetVersion ($DBversion);
-    print "Upgrade to $DBversion done (Bug 22880: Move contents of opacheader preference to Koha news system)\n";
+
+    unshift @detail, 'Move contents of opacheader preference to Koha news system';
+    NewVersion( $DBversion, 22880, \@detail);
 }
 
 $DBversion = '19.12.00.031';
@@ -20960,8 +20927,8 @@ if( CheckVersion( $DBversion ) ) {
     $dbh->do( q|
 ALTER TABLE article_requests MODIFY COLUMN created_on timestamp NULL, MODIFY COLUMN updated_on timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
     |);
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 22273: Column article_requests.created_on should not be updated)\n";
+
+    NewVersion( $DBversion, 22273, "Column article_requests.created_on should not be updated" );
 }
 
 $DBversion = '19.12.00.032';
@@ -20970,8 +20937,7 @@ if( CheckVersion( $DBversion ) ) {
         DELETE FROM systempreferences WHERE variable="UseQueryParser"
     |);
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24735 - Remove UseQueryParser system preference)\n";
+    NewVersion( $DBversion, 24735, "Remove UseQueryParser system preference" );
 }
 
 $DBversion = '19.12.00.033';
@@ -20999,9 +20965,7 @@ if ( CheckVersion($DBversion) ) {
         (25, 'cashup', 'Perform cash register cashup action')
     });
 
-    SetVersion($DBversion);
-    print "Upgrade to $DBversion done (Bug 23355 - Add cash_register_actions table)\n";
-    print "Upgrade to $DBversion done (Bug 23355 - Add cash register cashup permissions)\n";
+    NewVersion( $DBversion, 23355, [ "Add cash_register_actions table", "Add cash register cashup permissions" ] );
 }
 
 $DBversion = '19.12.00.034';
@@ -21029,8 +20993,7 @@ if ( CheckVersion($DBversion) ) {
     }
     );
 
-    SetVersion($DBversion);
-    print "Upgrade to $DBversion done (Bug 24081 - Add DISCOUNT to account_credit_types and account_offset_types, Add accounts discount permission)\n";
+    NewVersion( $DBversion, 24081, "Add DISCOUNT to account_credit_types and account_offset_types, Add accounts discount permission");
 }
 
 $DBversion = '19.12.00.035';
@@ -21042,8 +21005,7 @@ if ( CheckVersion($DBversion) ) {
         (25, 'anonymous_refund', 'Perform refund actions from cash registers')
     });
 
-    SetVersion($DBversion);
-    print "Upgrade to $DBversion done (Bug 23442 - Add a refund option to the point of sale system)\n";
+    NewVersion( $DBversion, 23442, "Add a refund option to the point of sale system" );
 }
 
 $DBversion = '19.12.00.036';
@@ -21055,8 +21017,7 @@ if( CheckVersion( $DBversion ) ) {
             ('AccessControlAllowOrigin', '', NULL, 'Set the Access-Control-Allow-Origin header to the specified value', 'Free');
     });
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24369 - Add CORS support to Koha)\n";
+    NewVersion( $DBversion, 24369, "Add CORS support to Koha");
 }
 
 $DBversion = '19.12.00.037';
@@ -21066,16 +21027,14 @@ if( CheckVersion( $DBversion ) ) {
     
     $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('RenewAccruingItemWhenPaid', '0', 'If enabled, when the fines on an item accruing is paid off, attempt to renew that item. If the syspref "RenewalPeriodBase" is set to "due date", renewed items may still be overdue', '', 'YesNo'); | );
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 23051 - Add RenewAccruingItemInOpac syspref)\n";
-    print "Upgrade to $DBversion done (Bug 23051 - Add RenewAccruingItemWhenPaid syspref)\n";
+    NewVersion( $DBversion, 23051, [ "Add RenewAccruingItemInOpac syspref", "Add RenewAccruingItemWhenPaid syspref" ]);
 }
 
 $DBversion = '19.12.00.038';
 if( CheckVersion( $DBversion ) ) {
     $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('CirculateILL', '0', 'If enabled, it is possible to circulate ILL requested items from within ILL', '', 'YesNo'); | );
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 23112  - Add CirculateILL syspref)\n";
+
+    NewVersion( $DBversion, 23112, "Add CirculateILL syspref");
 }
 
 $DBversion = '19.12.00.039';
@@ -21088,16 +21047,14 @@ if( CheckVersion( $DBversion ) ) {
 
     $dbh->do(qq{ DELETE FROM systempreferences WHERE variable = "printcirculationslips"} );
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 17845 - Drop unused table printers and branchprinter column)\n";
+    NewVersion( $DBversion, 17845, "Drop unused table printers and branchprinter column");
 }
 
 $DBversion = '19.12.00.040';
 if( CheckVersion( $DBversion ) ) {
     $dbh->do( "UPDATE systempreferences SET  explanation = 'Comma separated list defining the default fields to be used during a patron search using the \"standard\" option. If empty Koha will default to \"surname,firstname,othernames,cardnumber,userid\". Additional fields added to this preference will be added as search options in the dropdown menu on the patron search page.' WHERE variable='DefaultPatronSearchFields' " );
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 17374 - update description of DefaultPatronSearchFields)\n";
+    NewVersion( $DBversion, 17374, "Update description of DefaultPatronSearchFields");
 }
 
 $DBversion = '19.12.00.041';
@@ -21120,8 +21077,7 @@ if( CheckVersion( $DBversion ) ) {
         ALTER TABLE old_reserves MODIFY priority SMALLINT(6) NOT NULL DEFAULT 1
     |);
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 24722 - Enforce NOT NULL constraint for reserves.priority)\n";
+    NewVersion( $DBversion, 24722, "Enforce NOT NULL constraint for reserves.priority");
 }
 
 $DBversion = '19.12.00.042';
@@ -21130,8 +21086,205 @@ if( CheckVersion( $DBversion ) ) {
         $dbh->do('ALTER TABLE message_queue ADD COLUMN reply_address LONGTEXT AFTER from_address');
     }
 
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 22821 - Add reply_address to message_queue)\n";
+    NewVersion( $DBversion, 22821, "Add reply_address to message_queue");
+}
+
+$DBversion = '19.12.00.043';
+if( CheckVersion( $DBversion ) ) {
+
+    # Add return reasons to enum
+    $dbh->do(
+        qq{
+            ALTER TABLE
+                `branchtransfers`
+            MODIFY COLUMN
+                `reason` enum(
+                    'Manual',
+                    'StockrotationAdvance',
+                    'StockrotationRepatriation',
+                    'ReturnToHome',
+                    'ReturnToHolding'
+                )
+            AFTER `comments`
+          }
+    );
+
+    NewVersion( $DBversion, 24296, "Add 'return' reasons to branchtransfers enum");
+}
+
+$DBversion = '19.12.00.044';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(qq{
+        INSERT IGNORE permissions (module_bit, code, description)
+        VALUES
+        (13, 'batch_extend_due_dates', 'Perform batch extend due dates')
+    });
+
+    NewVersion( $DBversion, 24846, "Add a new permission for new tool batch extend due dates");
+}
+
+$DBversion = '19.12.00.045';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) 
+        VALUES
+        ('CollapseFieldsPatronAddForm','',NULL,'Collapse these fields by default when adding a new patron. These fields can still be expanded.','Multiple') 
+    });
+
+    NewVersion( $DBversion, 4461, "Add CollapseFieldsPatronAddForm system preference");
+}
+
+$DBversion = '19.12.00.046';
+if( CheckVersion( $DBversion ) ) {
+
+    $dbh->do( "ALTER TABLE accountlines MODIFY COLUMN date TIMESTAMP NULL" );
+
+    NewVersion( $DBversion, 24818, "Update 'accountlines.date' from DATE to TIMESTAMP");
+}
+
+$DBversion = '19.12.00.047';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+        ALTER TABLE biblioimages
+        ADD `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+        AFTER `thumbnail`;
+    });
+
+    NewVersion( $DBversion, 22987, "Add biblioimages.timestamp");
+}
+
+$DBversion = '19.12.00.048';
+if( CheckVersion( $DBversion ) ) {
+
+    # Add rotating collection states to reason enum
+    $dbh->do(
+        qq{
+            ALTER TABLE
+                `branchtransfers`
+            MODIFY COLUMN
+                `reason` enum(
+                    'Manual',
+                    'StockrotationAdvance',
+                    'StockrotationRepatriation',
+                    'ReturnToHome',
+                    'ReturnToHolding',
+                    'RotatingCollection'
+                )
+            AFTER `comments`
+          }
+    );
+
+    NewVersion( $DBversion, 24299, "Add 'collection' reasons to branchtransfers enum");
+}
+
+$DBversion = '19.12.00.049';
+if( CheckVersion( $DBversion ) ) {
+
+    # Add reserve reasons enum
+    $dbh->do(
+        qq{
+            ALTER TABLE
+                `branchtransfers`
+            MODIFY COLUMN
+                `reason` enum(
+                    'Manual',
+                    'StockrotationAdvance',
+                    'StockrotationRepatriation',
+                    'ReturnToHome',
+                    'ReturnToHolding',
+                    'RotatingCollection',
+                    'Reserve',
+                    'LostReserve',
+                    'CancelReserve'
+                )
+            AFTER `comments`
+          }
+    );
+
+    NewVersion( $DBversion, 24299, "Add 'reserve' reasons to branchtransfers enum");
+}
+
+$DBversion = '19.12.00.050';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do( "DELETE FROM systempreferences WHERE variable in ('IDreamBooksReadometer','IDreamBooksResults','IDreamBooksReviews')" );
+
+    NewVersion( $DBversion, 24854, "Remove IDreamBooks* system preferences");
+}
+
+$DBversion = '19.12.00.051';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(q{
+        UPDATE systempreferences SET options = 'itemhomebranch|patronhomebranch|checkoutbranch|none' WHERE variable='OpacRenewalBranch'
+    });
+    $dbh->do(q{
+        UPDATE systempreferences SET value = "none" WHERE variable='OpacRenewalBranch'
+        AND value = 'NULL'
+    });
+    $dbh->do(q{
+        UPDATE systempreferences SET value = 'opacrenew' WHERE variable='OpacRenewalBranch'
+        AND value NOT IN ('checkoutbranch','itemhomebranch','opacrenew','patronhomebranch','none')
+    });
+
+    NewVersion( $DBversion, 24759, "Cleanup OpacRenewalBranch");
+}
+
+$DBversion = '19.12.00.052';
+if( CheckVersion( $DBversion ) ) {
+    if( !column_exists( 'itemtypes', 'rentalcharge_daily_calendar' ) ) {
+        $dbh->do(q{
+            ALTER TABLE itemtypes ADD COLUMN
+            rentalcharge_daily_calendar tinyint(1) NOT NULL DEFAULT 1
+            AFTER rentalcharge_daily;
+        });
+    }
+
+    if( !column_exists( 'itemtypes', 'rentalcharge_hourly_calendar' ) ) {
+        $dbh->do(q{
+            ALTER TABLE itemtypes ADD COLUMN
+            rentalcharge_hourly_calendar tinyint(1) NOT NULL DEFAULT 1
+            AFTER rentalcharge_hourly;
+        });
+    }
+
+    my $finesCalendar = C4::Context->preference('finesCalendar');
+    my $value = $finesCalendar eq 'noFinesWhenClosed' ? 1 : 0;
+    $dbh->do("UPDATE itemtypes SET rentalcharge_hourly_calendar = $value, rentalcharge_daily_calendar = $value");
+
+    NewVersion( $DBversion, 21443, "Add ability to exclude holidays when calculating rentals fees by time period");
+}
+
+$DBversion = '19.12.00.053';
+if( CheckVersion( $DBversion ) ) {
+    unless( column_exists('borrowers','autorenew_checkouts') ){
+        $dbh->do( "ALTER TABLE borrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1 AFTER anonymized" );
+    }
+    unless( column_exists('deletedborrowers','autorenew_checkouts') ){
+        $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1 AFTER anonymized" );
+    }
+    $dbh->do(q{
+        INSERT IGNORE INTO systempreferences
+        ( `variable`, `value`, `options`, `explanation`, `type` )
+        VALUES
+        ('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account to choose whether their checkouts are auto renewed or not','YesNo')
+    });
+
+    NewVersion( $DBversion, 24476, "Allow patrons to opt-out of autorenewal");
+}
+
+$DBversion = '19.12.00.054';
+if( CheckVersion( $DBversion ) ) {
+    $dbh->do(qq{
+             CREATE TABLE desks ( -- desks available in a library
+             desk_id int(11) NOT NULL auto_increment, -- unique identifier added by Koha
+             desk_name varchar(100) NOT NULL default '', -- name of the desk
+             branchcode varchar(10) NOT NULL,       -- library the desk is located at
+             PRIMARY KEY  (desk_id),
+             KEY `fk_desks_branchcode` (branchcode),
+             CONSTRAINT `fk_desks_branchcode` FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
+             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+    });
+
+    NewVersion( $DBversion, 13881, "Add desk management");
 }
 
 # SEE bug 13068
@@ -21220,6 +21373,37 @@ sub SetVersion {
     C4::Context::clear_syspref_cache(); # invalidate cached preferences
 }
 
+sub NewVersion {
+    my ( $DBversion, $bug_number, $descriptions ) = @_;
+
+    SetVersion($DBversion);
+
+    unless ( ref($descriptions) ) {
+        $descriptions = [ $descriptions ];
+    }
+    my $first = 1;
+    my $time = POSIX::strftime("%H:%M:%S",localtime);
+    for my $description ( @$descriptions ) {
+        if ( @$descriptions > 1 ) {
+            if ( $first ) {
+                unless ( $bug_number ) {
+                    say sprintf "Upgrade to %s done [%s]: %s", $DBversion, $time, $description;
+                } else {
+                    say sprintf "Upgrade to %s done [%s]: Bug %5s - %s", $DBversion, $time, $bug_number, $description;
+                }
+            }
+            say sprintf "\t\t\t\t\t\t   - %s", $description;
+        } else {
+            unless ( $bug_number ) {
+                say sprintf "Upgrade to %s done [%s]: %s", $DBversion, $time, $description;
+            } else {
+                say sprintf "Upgrade to %s done [%s]: Bug %5s - %s", $DBversion, $time, $bug_number, $description;
+            }
+        }
+        $first = 0;
+    }
+}
+
 =head2 CheckVersion
 
 Check whether a given update should be run when passed the proposed version