From eb0c90c5270246d65c8571476fa88ebf00fe50ff Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 13 Oct 2021 16:06:09 +0000 Subject: [PATCH] Bug 29130: Make the temp tables persistent so unit tests can pass --- C4/HoldsQueue.pm | 8 ++------ installer/data/mysql/atomicupdate/bug_29130.pl | 12 ++++++++++++ installer/data/mysql/kohastructure.sql | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_29130.pl diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index c353f9ee9b8..28c0a5d8e50 100644 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -167,10 +167,8 @@ Top level function that turns reserves into tmp_holdsqueue and hold_fill_targets sub CreateQueue { my $dbh = C4::Context->dbh; - $dbh->do("DROP TABLE IF EXISTS tmp_holdsqueue_builder"); - $dbh->do("DROP TABLE IF EXISTS hold_fill_targets_builder"); - $dbh->do("CREATE TABLE tmp_holdsqueue_builder LIKE tmp_holdsqueue"); - $dbh->do("CREATE TABLE hold_fill_targets_builder LIKE hold_fill_targets"); + $dbh->do("DELETE FROM tmp_holdsqueue_builder"); + $dbh->do("DELETE FROM hold_fill_targets_builder"); my $total_bibs = 0; my $total_requests = 0; @@ -222,8 +220,6 @@ sub CreateQueue { $dbh->do("DELETE FROM hold_fill_targets"); $dbh->do("INSERT INTO tmp_holdsqueue SELECT * FROM tmp_holdsqueue_builder"); $dbh->do("INSERT INTO hold_fill_targets SELECT * FROM hold_fill_targets_builder"); - $dbh->do("DROP TABLE tmp_holdsqueue_builder"); - $dbh->do("DROP TABLE hold_fill_targets_builder"); $dbh->commit() unless $do_not_lock; } diff --git a/installer/data/mysql/atomicupdate/bug_29130.pl b/installer/data/mysql/atomicupdate/bug_29130.pl new file mode 100755 index 00000000000..eddf62ac6b9 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_29130.pl @@ -0,0 +1,12 @@ +use Modern::Perl; + +return { + bug_number => "29130", + description => "Create temp tables for holds queue builder", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + $dbh->do("CREATE TABLE tmp_holdsqueue_builder LIKE tmp_holdsqueue"); + $dbh->do("CREATE TABLE hold_fill_targets_builder LIKE hold_fill_targets"); + }, +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 95a3735906c..df791b12286 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2631,6 +2631,13 @@ CREATE TABLE `hold_fill_targets` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `hold_fill_targets_builder` is a duplicate of `hold_fill_targets` +-- + +DROP TABLE IF EXISTS `hold_fill_targets_builder`; +CREATE TABLE hold_fill_targets_builder LIKE tmp_holdsqueue; + -- -- Table structure for table `housebound_profile` -- @@ -5110,6 +5117,13 @@ CREATE TABLE `tmp_holdsqueue` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `tmp_holdsqueue_builder` is a duplicate of `tmp_holdsqueue` +-- + +DROP TABLE IF EXISTS `tmp_holdsqueue_builder`; +CREATE TABLE tmp_holdsqueue_builder LIKE tmp_holdsqueue; + -- -- Table structure for table `transport_cost` -- -- 2.20.1