Bugzilla – Attachment 97667 Details for
Bug 21674
Data integrity not enforced for library groups
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21674: Remove duplicates from library_groups before adding the uniq constraint
Bug-21674-Remove-duplicates-from-librarygroups-bef.patch (text/plain), 1.53 KB, created by
Jonathan Druart
on 2020-01-21 14:03:23 UTC
(
hide
)
Description:
Bug 21674: Remove duplicates from library_groups before adding the uniq constraint
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-01-21 14:03:23 UTC
Size:
1.53 KB
patch
obsolete
>From bae130d4fd357c585db685c3aef5d8f1db71efa6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 21 Jan 2020 15:01:51 +0100 >Subject: [PATCH] Bug 21674: Remove duplicates from library_groups before > adding the uniq constraint > >To avoid to make it fails if duplicates existed prior to this change >--- > installer/data/mysql/atomicupdate/bug_21674.perl | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > >diff --git a/installer/data/mysql/atomicupdate/bug_21674.perl b/installer/data/mysql/atomicupdate/bug_21674.perl >index 3bcf5f9f76..5242252571 100644 >--- a/installer/data/mysql/atomicupdate/bug_21674.perl >+++ b/installer/data/mysql/atomicupdate/bug_21674.perl >@@ -1,6 +1,19 @@ > $DBversion = 'XXX'; # will be replaced by the RM > if( CheckVersion( $DBversion ) ) { > if( !index_exists( 'library_groups', 'library_groups_uniq_2' ) ) { >+ my $library_groups = $dbh->selectall_arrayref(q|SELECT id, parent_id, branchcode FROM library_groups|, { Slice => {} }); >+ my %existing_groups; >+ for my $g ( @$library_groups ) { >+ >+ next unless $g->{parent_id}; >+ >+ unless ( exists $existing_groups{$g->{parent_id}}{$g->{branchcode}} ) { >+ $existing_groups{$g->{parent_id}}{$g->{branchcode}} = 1; >+ next; >+ } >+ >+ $dbh->do(q|DELETE FROM library_groups WHERE id=?|, undef, $g->{id}); >+ } > $dbh->do(q| > ALTER TABLE library_groups > ADD UNIQUE KEY library_groups_uniq_2 (parent_id, branchcode) >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21674
:
96199
|
96200
|
97658
|
97667
|
97811
|
97837
|
97838
|
97839
|
98170
|
98171
|
98172
|
98224