From a01e1f9b121b66c91300542b9a8401e303fe1b56 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 Mar 2020 09:55:03 +0100 Subject: [PATCH] Bug 24741: (bug 21674 follow-up) Fix destructive update DB 19.12.00.017 Previous version of the SQL query did not deal correctly with subgroup. Test plan: checkout the following commit to be just before 017 commit 715da06db557edc4b1baa51cc278fdac362c01c4 Bug 22868: DBRev 19.12.00.016 reset_all # recreate the DB Create a complex tree of library groups, with several groups, subgroups, etc. When you add a new library, refresh the page to add it several time. When ready, git checkout master, restart all the things, execute the updatedatabase script, then go to the library groups page. You should see that the duplicated entries have been removed, but subgroups have not been deleted --- installer/data/mysql/updatedatabase.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index df895366e2..764860c1a3 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20668,10 +20668,9 @@ if( CheckVersion( $DBversion ) ) { WHERE id NOT IN ( SELECT MIN(id) FROM ( SELECT * FROM library_groups ) AS lg - WHERE parent_id IS NOT NULL GROUP BY parent_id, branchcode ) - AND parent_id IS NOT NULL; + AND NOT(parent_id IS NULL OR branchcode IS NULL); |); $dbh->do(q| ALTER TABLE library_groups -- 2.20.1