From a5d015593ccd029c1eb46cc6a3a831b343562516 Mon Sep 17 00:00:00 2001 From: "Cameron E. Tidd" Date: Thu, 3 Jul 2025 17:06:49 +0000 Subject: [PATCH 01/16] reports_branches table SQL established --- installer/data/mysql/kohastructure.sql | 13 +++++++++++++ installer/data/mysql/updatedatabase.pl | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 5d7139383c..179cc2fef6 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -5772,6 +5772,19 @@ CREATE TABLE `saved_reports` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +DROP TABLE IF EXISTS `reports_branches`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `reports_branches` ( + `report_id` int(11) NOT NULL, + `branchcode` varchar(10) NOT NULL, + KEY `report_id` (`report_id`), + KEY `branchcode` (`branchcode`), + CONSTRAINT `reports_branches_ibfk_1` FOREIGN KEY (`report_id`) REFERENCES `saved_sql` (`id`) ON DELETE CASCADE, + CONSTRAINT `reports_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `saved_sql` -- diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index adbd5e4c50..ae9076abc5 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -29455,6 +29455,22 @@ if ( CheckVersion($DBversion) ) { NewVersion( $DBversion, 28108, "Add new systempreference OpacHiddenItemsHidesRecord" ); } +$DBversion = '20.12.00.051'; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do( + "CREATE TABLE `reports_branches` ( + `report_id` int(11) NOT NULL, + `branchcode` varchar(10) NOT NULL, + KEY `report_id` (`report_id`), + KEY `branchcode` (`branchcode`), + CONSTRAINT `reports_branches_ibfk_1` FOREIGN KEY (`report_id`) REFERENCES `saved_sql` (`id`) ON DELETE CASCADE, + CONSTRAINT `reports_branches_ibfk_2` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;" + ); + print "Upgrade to $DBversion done (reports_branches added)\n"; + SetVersion($DBversion); +} + $DBversion = '21.05.00.000'; if ( CheckVersion($DBversion) ) { NewVersion( $DBversion, "", "Koha 21.05.00 release" ); -- 2.39.5