@@ -, +, @@ adding the uniq constraint --- installer/data/mysql/atomicupdate/bug_21674.perl | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/installer/data/mysql/atomicupdate/bug_21674.perl +++ a/installer/data/mysql/atomicupdate/bug_21674.perl @@ -1,6 +1,16 @@ $DBversion = 'XXX'; # will be replaced by the RM if( CheckVersion( $DBversion ) ) { if( !index_exists( 'library_groups', 'library_groups_uniq_2' ) ) { + $dbh->do(q| + DELETE FROM library_groups + WHERE id NOT IN ( + SELECT MIN(id) + FROM library_groups + WHERE parent_id IS NOT NULL + GROUP BY parent_id, branchcode + ) + AND parent_id IS NOT NULL; + |); $dbh->do(q| ALTER TABLE library_groups ADD UNIQUE KEY library_groups_uniq_2 (parent_id, branchcode) --