From b2bf49af39d4678484f8da2b22b643bfcd965b9c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 10 May 2019 15:32:03 +0100 Subject: [PATCH] Bug 22887: Add unique constraint to authorised_values --- installer/data/mysql/atomicupdate/bug_22887.perl | 8 ++++++++ installer/data/mysql/kohastructure.sql | 1 + 2 files changed, 9 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_22887.perl diff --git a/installer/data/mysql/atomicupdate/bug_22887.perl b/installer/data/mysql/atomicupdate/bug_22887.perl new file mode 100644 index 0000000000..5744d84756 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_22887.perl @@ -0,0 +1,8 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( q{ALTER TABLE `authorised_values` ADD CONSTRAINT `category_code` UNIQUE (category,authorised_value)} ); + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 22887 - Add unique constraint to authorised_values)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 77224bcac3..99c393f674 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -119,6 +119,7 @@ CREATE TABLE `authorised_values` ( -- stores values for authorized values catego KEY `name` (`category`), KEY `lib` (`lib` (191)), KEY `auth_value_idx` (`authorised_value`), + CONSTRAINT `category_code` UNIQUE (`category`,`authorised_value`), CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.20.1