From a18e944400efd354f2b755459f45e249f8a24468 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 4 May 2020 09:23:19 +0100 Subject: [PATCH] Bug 24161: DBRev 19.12.00.085 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_24161.perl | 36 ------------------- installer/data/mysql/updatedatabase.pl | 35 ++++++++++++++++++ 3 files changed, 36 insertions(+), 37 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_24161.perl diff --git a/Koha.pm b/Koha.pm index d9dc6bafa3..c776504e61 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.12.00.084"; +$VERSION = "19.12.00.085"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_24161.perl b/installer/data/mysql/atomicupdate/bug_24161.perl deleted file mode 100644 index 16666759e1..0000000000 --- a/installer/data/mysql/atomicupdate/bug_24161.perl +++ /dev/null @@ -1,36 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - unless ( TableExists( 'aqorders_claims' ) ) { - $dbh->do(q| - CREATE TABLE aqorders_claims ( - id int(11) AUTO_INCREMENT, - ordernumber INT(11) NOT NULL, - claimed_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (id), - CONSTRAINT aqorders_claims_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci - |); - - my $orders = $dbh->selectall_arrayref(q| - SELECT ordernumber, claims_count, claimed_date - FROM aqorders - WHERE claims_count > 0 - |, { Slice => {} }); - my $insert_claim_sth = $dbh->prepare(q| - INSERT INTO aqorders_claims (ordernumber, claimed_on) - VALUES (?,?) - |); - - for my $order ( @$orders ) { - for my $claim (1..$order->{claims_count}) { - $insert_claim_sth->execute($order->{ordernumber}, $order->{claimed_on}); - } - } - - $dbh->do(q|ALTER TABLE aqorders DROP COLUMN claims_count, DROP COLUMN claimed_date|); - } - - # Always end with this (adjust the bug info) - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 24161 - Add new join table aqorders_claims to keep track of claims)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d28064a712..f9732b83dc 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -21993,6 +21993,41 @@ if( CheckVersion( $DBversion ) ) { NewVersion( $DBversion, 17682, "Add macros db table and permissions"); } +$DBversion = '19.12.00.085'; +if( CheckVersion( $DBversion ) ) { + unless ( TableExists( 'aqorders_claims' ) ) { + $dbh->do(q| + CREATE TABLE aqorders_claims ( + id int(11) AUTO_INCREMENT, + ordernumber INT(11) NOT NULL, + claimed_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (id), + CONSTRAINT aqorders_claims_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci + |); + + my $orders = $dbh->selectall_arrayref(q| + SELECT ordernumber, claims_count, claimed_date + FROM aqorders + WHERE claims_count > 0 + |, { Slice => {} }); + my $insert_claim_sth = $dbh->prepare(q| + INSERT INTO aqorders_claims (ordernumber, claimed_on) + VALUES (?,?) + |); + + for my $order ( @$orders ) { + for my $claim (1..$order->{claims_count}) { + $insert_claim_sth->execute($order->{ordernumber}, $order->{claimed_on}); + } + } + + $dbh->do(q|ALTER TABLE aqorders DROP COLUMN claims_count, DROP COLUMN claimed_date|); + } + + NewVersion( $DBversion, 24161, "Add new join table aqorders_claims to keep track of claims"); +} + # 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.39.5