Bug 22899: DBRev 18.12.00.075

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2019-05-14 18:15:54 +00:00
parent 5c81d98621
commit b90bbc1259
5 changed files with 63 additions and 24 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 = "18.12.00.074";
$VERSION = "18.12.00.075";
sub version {
return $VERSION;

View File

@ -701,9 +701,24 @@ __PACKAGE__->might_have(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 tmp_holdsqueues
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-09 15:50:42
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PQvA8qoxvTe4In5/oa5WIQ
Type: has_many
Related object: L<Koha::Schema::Result::TmpHoldsqueue>
=cut
__PACKAGE__->has_many(
"tmp_holdsqueues",
"Koha::Schema::Result::TmpHoldsqueue",
{ "foreign.itemnumber" => "self.itemnumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-14 18:14:09
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wDXcErUYqg0aoQkzz3P5vg
__PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );

View File

@ -31,6 +31,7 @@ __PACKAGE__->table("tmp_holdsqueue");
=head2 itemnumber
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 barcode
@ -111,7 +112,7 @@ __PACKAGE__->add_columns(
"biblionumber",
{ data_type => "integer", is_nullable => 1 },
"itemnumber",
{ data_type => "integer", is_nullable => 1 },
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"barcode",
{ data_type => "varchar", is_nullable => 1, size => 20 },
"surname",
@ -140,9 +141,31 @@ __PACKAGE__->add_columns(
{ data_type => "tinyint", default_value => 0, is_nullable => 0 },
);
=head1 RELATIONS
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1Wa4h3u3FePOhGPD8SHEWg
=head2 itemnumber
Type: belongs_to
Related object: L<Koha::Schema::Result::Item>
=cut
__PACKAGE__->belongs_to(
"itemnumber",
"Koha::Schema::Result::Item",
{ itemnumber => "itemnumber" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-14 18:14:09
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tzgAgf+OVO+IncaTr7SZuQ
# You can replace this text with custom content, and it will be preserved on regeneration

View File

@ -1,18 +0,0 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
# you can use $dbh here like:
unless ( foreign_key_exists( 'tmp_holdsqueue', 'tmp_holdsqueue_ibfk_1' ) ) {
$dbh->do(q{
DELETE t FROM tmp_holdsqueue t
LEFT JOIN items i ON t.itemnumber=i.itemnumber
WHERE i.itemnumber IS NULL
});
$dbh->do(q{
ALTER TABLE tmp_holdsqueue
ADD CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`)
REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
});
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug XXXXX - Add items constraint to tmp_holdsqueue)\n";
}

View File

@ -18657,6 +18657,25 @@ if( CheckVersion( $DBversion ) ) {
print "Upgrade to $DBversion done (Bug 21411 - Add keyboard_shortcuts table)\n";
}
$DBversion = '18.12.00.075';
if( CheckVersion( $DBversion ) ) {
# you can use $dbh here like:
unless ( foreign_key_exists( 'tmp_holdsqueue', 'tmp_holdsqueue_ibfk_1' ) ) {
$dbh->do(q{
DELETE t FROM tmp_holdsqueue t
LEFT JOIN items i ON t.itemnumber=i.itemnumber
WHERE i.itemnumber IS NULL
});
$dbh->do(q{
ALTER TABLE tmp_holdsqueue
ADD CONSTRAINT `tmp_holdsqueue_ibfk_1` FOREIGN KEY (`itemnumber`)
REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
});
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 22899 - Add items constraint to tmp_holdsqueue)\n";
}
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.