From d82e31ab13d658dae7b1385692064d570752be42 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 5 Aug 2019 13:29:10 +0100 Subject: [PATCH] Bug 22610: DBRev 19.06.017 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_22610.perl | 74 ------------------ installer/data/mysql/updatedatabase.pl | 75 +++++++++++++++++++ 3 files changed, 76 insertions(+), 75 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_22610.perl diff --git a/Koha.pm b/Koha.pm index fac5a4f325..4fb19e726e 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "19.06.00.016"; +$VERSION = "19.06.00.017"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_22610.perl b/installer/data/mysql/atomicupdate/bug_22610.perl deleted file mode 100644 index b31285f10f..0000000000 --- a/installer/data/mysql/atomicupdate/bug_22610.perl +++ /dev/null @@ -1,74 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if ( CheckVersion($DBversion) ) { - - $dbh->do(qq{ - INSERT INTO - authorised_values (category,authorised_value,lib) - VALUES - ('PAYMENT_TYPE','SIP00','Cash via SIP2'), - ('PAYMENT_TYPE','SIP01','VISA via SIP2'), - ('PAYMENT_TYPE','SIP02','Creditcard via SIP2') - }); - - $dbh->do(qq{ - UPDATE - accountlines - SET - accounttype = 'Pay', - payment_type = 'SIP00' - WHERE - accounttype = 'Pay00'; - }); - - $dbh->do(qq{ - UPDATE - accountlines - SET - accounttype = 'Pay', - payment_type = 'SIP01' - WHERE - accounttype = 'Pay01'; - }); - - $dbh->do(qq{ - UPDATE - accountlines - SET - accounttype = 'Pay', - payment_type = 'SIP02' - WHERE - accounttype = 'Pay02'; - }); - - my $sth = $dbh->prepare( qq{SELECT * FROM accountlines WHERE accounttype REGEXP '^Pay[[:digit:]]{2}$' } ); - $sth->execute(); - my $seen = {}; - while (my $row = $sth->fetchrow_hashref) { - my $type = $row->{accounttype}; - my $sipcode = $type; - $sipcode =~ s/Pay/SIP/g; - unless ($seen->{$sipcode}) { - $dbh->do(qq{ - INSERT INTO - authorised_values (category,authorised_value,lib) - VALUES - ('PAYMENT_TYPE',"$sipcode",'Unrecognised SIP2 payment type') - }); - - $dbh->do(qq{ - UPDATE - accountlines - SET - accounttype = 'Pay', - payment_type = "$sipcode" - WHERE - accounttype = "$type"; - }); - - $seen->{$sipcode} = 1; - } - } - - SetVersion($DBversion); - print "Upgrade to $DBversion done (Bug 22610 - Fix accounttypes for SIP2 payments)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index e9423cf5c7..45f81e796e 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -19069,6 +19069,81 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 23396 - Fix missing keyboard_shortcuts table)\n"; } +$DBversion = '19.06.00.017'; +if ( CheckVersion($DBversion) ) { + + $dbh->do(qq{ + INSERT INTO + authorised_values (category,authorised_value,lib) + VALUES + ('PAYMENT_TYPE','SIP00','Cash via SIP2'), + ('PAYMENT_TYPE','SIP01','VISA via SIP2'), + ('PAYMENT_TYPE','SIP02','Creditcard via SIP2') + }); + + $dbh->do(qq{ + UPDATE + accountlines + SET + accounttype = 'Pay', + payment_type = 'SIP00' + WHERE + accounttype = 'Pay00'; + }); + + $dbh->do(qq{ + UPDATE + accountlines + SET + accounttype = 'Pay', + payment_type = 'SIP01' + WHERE + accounttype = 'Pay01'; + }); + + $dbh->do(qq{ + UPDATE + accountlines + SET + accounttype = 'Pay', + payment_type = 'SIP02' + WHERE + accounttype = 'Pay02'; + }); + + my $sth = $dbh->prepare( q{SELECT * FROM accountlines WHERE accounttype REGEXP '^Pay[[:digit:]]{2}$' } ); + $sth->execute(); + my $seen = {}; + while (my $row = $sth->fetchrow_hashref) { + my $type = $row->{accounttype}; + my $sipcode = $type; + $sipcode =~ s/Pay/SIP/g; + unless ($seen->{$sipcode}) { + $dbh->do(qq{ + INSERT INTO + authorised_values (category,authorised_value,lib) + VALUES + ('PAYMENT_TYPE',"$sipcode",'Unrecognised SIP2 payment type') + }); + + $dbh->do(qq{ + UPDATE + accountlines + SET + accounttype = 'Pay', + payment_type = "$sipcode" + WHERE + accounttype = "$type"; + }); + + $seen->{$sipcode} = 1; + } + } + + SetVersion($DBversion); + print "Upgrade to $DBversion done (Bug 22610 - Fix accounttypes for SIP2 payments)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.20.1