Browse Source

Bug 13515: DBRev 18.12.00.014

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
19.05.x
Nick Clemens 4 years ago
parent
commit
2c6d39452a
  1. 2
      Koha.pm
  2. 19
      Koha/Schema/Result/Borrower.pm
  3. 22
      Koha/Schema/Result/Message.pm
  4. 20
      installer/data/mysql/atomicupdate/bug_13515.perl
  5. 18
      installer/data/mysql/updatedatabase.pl

2
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 = "18.12.00.013";
$VERSION = "18.12.00.014";
sub version {
return $VERSION;

19
Koha/Schema/Result/Borrower.pm

@ -1115,6 +1115,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 messages_borrowernumbers
Type: has_many
Related object: L<Koha::Schema::Result::Message>
=cut
__PACKAGE__->has_many(
"messages_borrowernumbers",
"Koha::Schema::Result::Message",
{ "foreign.borrowernumber" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 old_issues
Type: has_many
@ -1431,8 +1446,8 @@ Composing rels: L</aqorder_users> -> ordernumber
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-27 13:16:48
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:c3Tb59Kku0Hh+tsVV5eCDg
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-02-15 13:15:09
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NhuG8jv9ut+qIIm3vGHsrQ
__PACKAGE__->belongs_to(
"guarantor",

22
Koha/Schema/Result/Message.pm

@ -32,6 +32,7 @@ __PACKAGE__->table("messages");
=head2 borrowernumber
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 branchcode
@ -70,7 +71,7 @@ __PACKAGE__->add_columns(
"message_id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"borrowernumber",
{ data_type => "integer", is_nullable => 0 },
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"branchcode",
{ data_type => "varchar", is_nullable => 1, size => 10 },
"message_type",
@ -102,6 +103,21 @@ __PACKAGE__->set_primary_key("message_id");
=head1 RELATIONS
=head2 borrowernumber
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"borrowernumber",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "borrowernumber" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 manager
Type: belongs_to
@ -123,8 +139,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cNf9ogl9bN+0BC63dS1rmA
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-02-15 13:15:09
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kYM+0CFPm/wdNp7EosdlRw
# You can replace this text with custom content, and it will be preserved on regeneration

20
installer/data/mysql/atomicupdate/bug_13515.perl

@ -1,20 +0,0 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
unless( foreign_key_exists( 'messages', 'messages_borrowernumber' ) ) {
$dbh->do(q|
DELETE m FROM messages m
LEFT JOIN borrowers b ON m.borrowernumber=b.borrowernumber
WHERE b.borrowernumber IS NULL
|);
$dbh->do(q|
ALTER TABLE messages
ADD CONSTRAINT messages_borrowernumber
FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
|);
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 13515 - Add a FOREIGN KEY constaint on messages.borrowernumber)\n";
}

18
installer/data/mysql/updatedatabase.pl

@ -17330,6 +17330,24 @@ if( CheckVersion( $DBversion ) ) {
print "Upgrade to $DBversion done (Bug 22198 - Add ghranular permission setting for Mana KB)\n";
}
$DBversion = '18.12.00.014';
if( CheckVersion( $DBversion ) ) {
unless( foreign_key_exists( 'messages', 'messages_borrowernumber' ) ) {
$dbh->do(q|
DELETE m FROM messages m
LEFT JOIN borrowers b ON m.borrowernumber=b.borrowernumber
WHERE b.borrowernumber IS NULL
|);
$dbh->do(q|
ALTER TABLE messages
ADD CONSTRAINT messages_borrowernumber
FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
|);
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 13515 - Add a FOREIGN KEY constaint on messages.borrowernumber)\n";
}
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.

Loading…
Cancel
Save