From 2630a8f77c6218eee0ac5370f36f090056a10ed8 Mon Sep 17 00:00:00 2001 From: Baptiste Date: Wed, 4 Dec 2024 17:22:06 +0100 Subject: [PATCH] Bug 35292: Database changes --- ...pdateNotForLoanStatusOnCheckOut_syspref.pl | 35 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100755 installer/data/mysql/atomicupdate/bug_35292-amend_UpdateNotForLoanStatusOnCheckOut_syspref.pl diff --git a/installer/data/mysql/atomicupdate/bug_35292-amend_UpdateNotForLoanStatusOnCheckOut_syspref.pl b/installer/data/mysql/atomicupdate/bug_35292-amend_UpdateNotForLoanStatusOnCheckOut_syspref.pl new file mode 100755 index 00000000000..ad866723d6b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_35292-amend_UpdateNotForLoanStatusOnCheckOut_syspref.pl @@ -0,0 +1,35 @@ +use Modern::Perl; + +return { + bug_number => "35292", + description => "Migrating existing UpdateNotForLoanStatusOnCheckout rules to new format", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + my ($UpdateNotForLoanStatusOnCheckout) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='UpdateNotForLoanStatusOnCheckout' + | + ); + + my ( $new_rules, $updated_rules ); + if ( $UpdateNotForLoanStatusOnCheckout && $UpdateNotForLoanStatusOnCheckout !~ /[0-9a-zA-Z_]:\r/ ) { + + # Split and re-format the existing rules under a single _ALL_ special term to affect all itemtypes + my @rules = split /\r/, $UpdateNotForLoanStatusOnCheckout; + foreach my $rule (@rules) { + $rule =~ s/^\s+|\s+$|\r|\n//g; + $new_rules .= ' ' . $rule . "\r"; + } + $updated_rules .= "_ALL_:\r$new_rules\r"; + $dbh->do( + qq{ + UPDATE systempreferences + SET value = '$updated_rules', explanation = "This is a list of item types and value pairs.\nExamples:\n_ALL_:\n -1: 0\n\nCR:\n 1: 0\n\nWhen an item is checked out, if its item type matches CR then when the value on the left (1) matches the items' not for loan value it will be updated to the value on the right.\n\nThe special term _ALL_ is used on the left side of the colon (:) to affect all item types. This does not override all other rules\n\nEach item type needs to be defined on a separate line on the left side of the colon (:).\nEach pair of not for loan values, for that item type, should be listed on separate lines below the item type, each indented by a leading space." + WHERE variable = 'UpdateNotForLoanStatusOnCheckout' + } + ); + } + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 2bf9d0b6486..a765ad786bf 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -829,7 +829,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('UpdateItemLostStatusWhenWriteoff', '0', NULL, 'Allows the status of lost items to be automatically changed to lost and paid for when written off', 'Integer'), ('UpdateItemWhenLostFromHoldList','',NULL,'This is a list of values to update an item when it is marked as lost from the holds to pull screen','Free'), ('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of item types and value pairs.\nExamples:\n_ALL_:\n -1: 0\n\nCR:\n 1: 0\n\nWhen an item is checked in, if its item type matches CR then when the value on the left (1) matches the items not for loan value it will be updated to the value on the right.\n\nThe special term _ALL_ is used on the left side of the colon (:) to affect all item types. This does not override all other rules\n\nEach item type needs to be defined on a separate line on the left side of the colon (:).\nEach pair of not for loan values, for that item type, should be listed on separate lines below the item type, each indented by a leading space.', 'Free'), -('UpdateNotForLoanStatusOnCheckout', '', 'NULL', 'This is a list of value pairs. When an item is checked out, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'), +('UpdateNotForLoanStatusOnCheckout', '', 'NULL', 'This is a list of item types and value pairs.\nExamples:\n_ALL_:\n -1: 0\n\nCR:\n 1: 0\n\nWhen an item is checked out, if its item type matches CR then when the value on the left (1) matches the items not for loan value it will be updated to the value on the right.\n\nThe special term _ALL_ is used on the left side of the colon (:) to affect all item types. This does not override all other rules\n\nEach item type needs to be defined on a separate line on the left side of the colon (:).\nEach pair of not for loan values, for that item type, should be listed on separate lines below the item type, each indented by a leading space.', 'Free'), ('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'), ('UploadPurgeTemporaryFilesDays','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'), ('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'), -- 2.30.2