From e12a72d71dd4cf67d053e0d7bc6f352173eb48d5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 28 May 2013 16:09:41 +0200 Subject: [PATCH] Bug 10363: DB Changes: Adds a unique key for the authorised values table. Content-Type: text/plain; charset=utf-8 Signed-off-by: Kyle M Hall Signed-off-by: Bernardo Gonzalez Kriegel --- installer/data/mysql/kohastructure.sql | 1 + installer/data/mysql/updatedatabase.pl | 10 ++++++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 363217b..88d0f28 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -104,6 +104,7 @@ CREATE TABLE `authorised_values` ( -- stores values for authorized values catego `lib_opac` varchar(200) default NULL, -- authorized value description as printed in the OPAC `imageurl` varchar(200) default NULL, -- authorized value URL PRIMARY KEY (`id`), + UNIQUE KEY `av_uniq` (`category`,`authorised_value`), KEY `name` (`category`), KEY `lib` (`lib`), KEY `auth_value_idx` (`authorised_value`) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index f043d0b..62ccf84 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7953,6 +7953,16 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.15.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{ + ALTER TABLE authorised_values ADD UNIQUE KEY av_uniq(category, authorised_value); + }); + print "Upgrade to $DBversion done (Bug XXXXX: Add unique key on the authorised_values table)\n"; + SetVersion($DBversion); +} + + =head1 FUNCTIONS =head2 TableExists($table) -- 1.7.7.6