From cca2a0827043770877e6db3c7b13a2d6f263d4e6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 30 Jan 2020 15:44:17 +0000 Subject: [PATCH] Bug 21674: DBRev 19.12.00.017 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- Koha/Schema/Result/LibraryGroup.pm | 18 +++++++++++++-- .../data/mysql/atomicupdate/bug_21674.perl | 22 ------------------ installer/data/mysql/updatedatabase.pl | 23 +++++++++++++++++++ 4 files changed, 40 insertions(+), 25 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_21674.perl diff --git a/Koha.pm b/Koha.pm index 0d6acad667..31613b5dd2 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "19.12.00.016"; +$VERSION = "19.12.00.017"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/LibraryGroup.pm b/Koha/Schema/Result/LibraryGroup.pm index 3be173edb0..6ffb7a8ac4 100644 --- a/Koha/Schema/Result/LibraryGroup.pm +++ b/Koha/Schema/Result/LibraryGroup.pm @@ -140,6 +140,20 @@ __PACKAGE__->set_primary_key("id"); =head1 UNIQUE CONSTRAINTS +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("library_groups_uniq_2", ["parent_id", "branchcode"]); + =head2 C =over 4 @@ -210,8 +224,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-07-03 22:28:33 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mJMYVtlB3JfqMEmNa0SWdg +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-01-30 15:43:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:qg0Ckj0ZBRjSaQgEcvxSZA sub koha_object_class { 'Koha::Library::Group'; diff --git a/installer/data/mysql/atomicupdate/bug_21674.perl b/installer/data/mysql/atomicupdate/bug_21674.perl deleted file mode 100644 index 418f3f5d24..0000000000 --- a/installer/data/mysql/atomicupdate/bug_21674.perl +++ /dev/null @@ -1,22 +0,0 @@ -$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) - |); - } - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 21674 - Add unique key (parent_id, branchcode) to library_group)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index e4fa236c0a..0468db0f71 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20660,6 +20660,29 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 22868 - Move suggestions_manage subpermission out of acquisition permission)\n"; } +$DBversion = '19.12.00.017'; +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) + |); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 21674 - Add unique key (parent_id, branchcode) to library_group)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.20.1