From 89fb8305c676aa6c91aaeddd3bfa17d436d0cc28 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 29 Oct 2025 17:56:49 +0000 Subject: [PATCH] Bug 40529: (QA follow-up): Add UNIQUE KEY entries to table definition The UNIQUE KEY are required as a hold group 'might have' a target hold, not 'has many' target holds. This update and the other things this patch updates in atomicupdate + kohastructure should fix the error thrown by command: perl /kohadevbox/misc4dev/run_tests.pl --instance=kohadev --db-password=password --run-db-compare-only --compare-with=HEAD But they don't, the error still complains: ERROR - DB structures are not identical Even thought the produced table from atomicupdate and table on kohastructure are exactly the same, line for line. --- .../bug_40529_-_hold_group_table_target.pl | 10 ++++++---- installer/data/mysql/kohastructure.sql | 12 +++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_40529_-_hold_group_table_target.pl b/installer/data/mysql/atomicupdate/bug_40529_-_hold_group_table_target.pl index bff6bd7504b..d6d44d1cf44 100755 --- a/installer/data/mysql/atomicupdate/bug_40529_-_hold_group_table_target.pl +++ b/installer/data/mysql/atomicupdate/bug_40529_-_hold_group_table_target.pl @@ -11,10 +11,12 @@ return { unless ( TableExists('hold_group_target_holds') ) { $dbh->do( q{ - CREATE TABLE hold_group_target_holds ( - `hold_group_id` int unsigned NOT NULL UNIQUE COMMENT 'foreign key, linking this to the hold_groups table', - `reserve_id` int(11) DEFAULT NULL UNIQUE COMMENT 'foreign key, linking this to the reserves table', - PRIMARY KEY (`hold_group_id`, `reserve_id`), + CREATE TABLE `hold_group_target_holds` ( + `hold_group_id` int(10) unsigned NOT NULL COMMENT 'foreign key, linking this to the hold_groups table', + `reserve_id` int(11) NOT NULL COMMENT 'foreign key, linking this to the reserves table', + PRIMARY KEY (`hold_group_id`,`reserve_id`), + UNIQUE KEY `uq_hold_group_target_holds_hold_group_id` (`hold_group_id`), + UNIQUE KEY `uq_hold_group_target_holds_reserve_id` (`reserve_id`), CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE, CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 56def5468e2..70952cbd2ca 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -5118,11 +5118,13 @@ CREATE TABLE `old_issues` ( -- DROP TABLE IF EXISTS `hold_group_target_holds`; /*!40101 SET @saved_cs_client = @@character_set_client */; -/*!40101 SET character_set_client = utf8 */; -CREATE TABLE hold_group_target_holds ( - `hold_group_id` int unsigned NOT NULL UNIQUE COMMENT 'foreign key, linking this to the hold_groups table', - `reserve_id` int(11) DEFAULT NULL UNIQUE COMMENT 'foreign key, linking this to the reserves table', - PRIMARY KEY (`hold_group_id`, `reserve_id`), +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `hold_group_target_holds` ( + `hold_group_id` int(10) unsigned NOT NULL COMMENT 'foreign key, linking this to the hold_groups table', + `reserve_id` int(11) NOT NULL COMMENT 'foreign key, linking this to the reserves table', + PRIMARY KEY (`hold_group_id`,`reserve_id`), + UNIQUE KEY `uq_hold_group_target_holds_hold_group_id` (`hold_group_id`), + UNIQUE KEY `uq_hold_group_target_holds_reserve_id` (`reserve_id`), CONSTRAINT `hold_group_target_holds_ibfk_1` FOREIGN KEY (`hold_group_id`) REFERENCES `hold_groups` (`hold_group_id`) ON DELETE CASCADE, CONSTRAINT `hold_group_target_holds_ibfk_2` FOREIGN KEY (`reserve_id`) REFERENCES `reserves` (`reserve_id`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.39.5