From 24e11b301cebf44f4741fd773a0e40baeb36f4c7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 11 Dec 2019 12:51:14 +0100 Subject: [PATCH] Bug 21674: DB changes --- installer/data/mysql/atomicupdate/bug_21674.perl | 12 ++++++++++++ installer/data/mysql/kohastructure.sql | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug_21674.perl diff --git a/installer/data/mysql/atomicupdate/bug_21674.perl b/installer/data/mysql/atomicupdate/bug_21674.perl new file mode 100644 index 0000000000..3bcf5f9f76 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_21674.perl @@ -0,0 +1,12 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + if( !index_exists( 'library_groups', 'library_groups_uniq_2' ) ) { + $dbh->do(q| + ALTER TABLE library_groups + ADD UNIQUE KEY library_groups_uniq_2 (parent_id, branchcode) + |); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 21674 - Add unique key (parent_id, branchcode) to library_group)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 67495ab962..791c95a781 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4280,7 +4280,8 @@ CREATE TABLE library_groups ( PRIMARY KEY id ( id ), FOREIGN KEY (parent_id) REFERENCES library_groups(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON UPDATE CASCADE ON DELETE CASCADE, - UNIQUE KEY title ( title ) + UNIQUE KEY title ( title ), + UNIQUE KEY library_groups_uniq_2 ( parent_id, branchcode ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- 2.11.0