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 715da06db5
  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

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Tested with duplicated entries on groups and subgroups,
going back to the right commit and doing clean install.
Patch works, subgroups are preserved. No errors.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2020-03-03 09:55:03 +01:00 committed by Martin Renvoize
parent 027f72da7c
commit 5b78de6cef
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -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