Bug 21674: DBRev 19.12.00.017

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2020-01-30 15:44:17 +00:00
parent 3134736a84
commit cca2a08270
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 40 additions and 25 deletions

View File

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

View File

@ -140,6 +140,20 @@ __PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<library_groups_uniq_2>
=over 4
=item * L</parent_id>
=item * L</branchcode>
=back
=cut
__PACKAGE__->add_unique_constraint("library_groups_uniq_2", ["parent_id", "branchcode"]);
=head2 C<title>
=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';

View File

@ -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";
}

View File

@ -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/';