@@ -, +, @@ --- 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 --- a/installer/data/mysql/atomicupdate/bug_21674.perl +++ a/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"; +} --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -4286,7 +4286,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; -- --