Bug 19618: DBRev 19.06.00.030

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-10-01 08:12:28 +01:00
parent 7d847c2294
commit 7a68532048
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
10 changed files with 458 additions and 53 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.06.00.029";
$VERSION = "19.06.00.030";
sub version {
return $VERSION;

View file

@ -240,6 +240,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_holds
Type: has_many
Related object: L<Koha::Schema::Result::ClubHold>
=cut
__PACKAGE__->has_many(
"club_holds",
"Koha::Schema::Result::ClubHold",
{ "foreign.biblio_id" => "self.biblionumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 hold_fill_targets
Type: has_many
@ -391,8 +406,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-08-05 13:53:34
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AzvuQItPPs5WeC4tdtS/NQ
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:otCex8qzJmZyc+JXpKNdpQ
__PACKAGE__->has_one(

View file

@ -959,6 +959,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_holds_to_patron_holds
Type: has_many
Related object: L<Koha::Schema::Result::ClubHoldsToPatronHold>
=cut
__PACKAGE__->has_many(
"club_holds_to_patron_holds",
"Koha::Schema::Result::ClubHoldsToPatronHold",
{ "foreign.patron_id" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 course_instructors
Type: has_many
@ -1560,8 +1575,8 @@ Composing rels: L</aqorder_users> -> ordernumber
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-22 04:33:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lbMdmIHlRt+zayG5+Rq4/w
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FRyurgV8tVN4EBduIM8tGA
__PACKAGE__->add_columns(
'+anonymized' => { is_boolean => 1 },

View file

@ -173,6 +173,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_holds
Type: has_many
Related object: L<Koha::Schema::Result::ClubHold>
=cut
__PACKAGE__->has_many(
"club_holds",
"Koha::Schema::Result::ClubHold",
{ "foreign.club_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_template
Type: belongs_to
@ -189,8 +204,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6EB6FURHN+brOhDoPZVeGQ
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WbB7PSSU4xaszsKe9Eacqw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -0,0 +1,162 @@
use utf8;
package Koha::Schema::Result::ClubHold;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::ClubHold
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<club_holds>
=cut
__PACKAGE__->table("club_holds");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 club_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 biblio_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 item_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 date_created
data_type: 'timestamp'
datetime_undef_if_invalid: 1
default_value: current_timestamp
is_nullable: 0
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"club_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"biblio_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"item_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"date_created",
{
data_type => "timestamp",
datetime_undef_if_invalid => 1,
default_value => \"current_timestamp",
is_nullable => 0,
},
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 RELATIONS
=head2 biblio
Type: belongs_to
Related object: L<Koha::Schema::Result::Biblio>
=cut
__PACKAGE__->belongs_to(
"biblio",
"Koha::Schema::Result::Biblio",
{ biblionumber => "biblio_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 club
Type: belongs_to
Related object: L<Koha::Schema::Result::Club>
=cut
__PACKAGE__->belongs_to(
"club",
"Koha::Schema::Result::Club",
{ id => "club_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 club_holds_to_patron_holds
Type: has_many
Related object: L<Koha::Schema::Result::ClubHoldsToPatronHold>
=cut
__PACKAGE__->has_many(
"club_holds_to_patron_holds",
"Koha::Schema::Result::ClubHoldsToPatronHold",
{ "foreign.club_hold_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 item
Type: belongs_to
Related object: L<Koha::Schema::Result::Item>
=cut
__PACKAGE__->belongs_to(
"item",
"Koha::Schema::Result::Item",
{ itemnumber => "item_id" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FYGXVx1P2R+dGbeP1xshPA
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -0,0 +1,167 @@
use utf8;
package Koha::Schema::Result::ClubHoldsToPatronHold;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::ClubHoldsToPatronHold
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<club_holds_to_patron_holds>
=cut
__PACKAGE__->table("club_holds_to_patron_holds");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
=head2 club_hold_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 patron_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 hold_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 error_code
data_type: 'enum'
extra: {list => ["damaged","ageRestricted","itemAlreadyOnHold","tooManyHoldsForThisRecord","tooManyReservesToday","tooManyReserves","notReservable","cannotReserveFromOtherBranches","libraryNotFound","libraryNotPickupLocation","cannotBeTransferred"]}
is_nullable: 1
=head2 error_message
data_type: 'varchar'
is_nullable: 1
size: 100
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"club_hold_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"patron_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"hold_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"error_code",
{
data_type => "enum",
extra => {
list => [
"damaged",
"ageRestricted",
"itemAlreadyOnHold",
"tooManyHoldsForThisRecord",
"tooManyReservesToday",
"tooManyReserves",
"notReservable",
"cannotReserveFromOtherBranches",
"libraryNotFound",
"libraryNotPickupLocation",
"cannotBeTransferred",
],
},
is_nullable => 1,
},
"error_message",
{ data_type => "varchar", is_nullable => 1, size => 100 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 RELATIONS
=head2 club_hold
Type: belongs_to
Related object: L<Koha::Schema::Result::ClubHold>
=cut
__PACKAGE__->belongs_to(
"club_hold",
"Koha::Schema::Result::ClubHold",
{ id => "club_hold_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 hold
Type: belongs_to
Related object: L<Koha::Schema::Result::Reserve>
=cut
__PACKAGE__->belongs_to(
"hold",
"Koha::Schema::Result::Reserve",
{ reserve_id => "hold_id" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
);
=head2 patron
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"patron",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "patron_id" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/T626DfqUi7SnXOyieUzYw
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View file

@ -511,6 +511,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 club_holds
Type: has_many
Related object: L<Koha::Schema::Result::ClubHold>
=cut
__PACKAGE__->has_many(
"club_holds",
"Koha::Schema::Result::ClubHold",
{ "foreign.item_id" => "self.itemnumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 course_item
Type: might_have
@ -717,8 +732,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-14 18:14:09
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wDXcErUYqg0aoQkzz3P5vg
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:47
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:n/X6k+IwU4pkLS+PjKWVWA
__PACKAGE__->belongs_to( biblioitem => "Koha::Schema::Result::Biblioitem", "biblioitemnumber" );

View file

@ -280,6 +280,21 @@ __PACKAGE__->belongs_to(
},
);
=head2 club_holds_to_patron_holds
Type: has_many
Related object: L<Koha::Schema::Result::ClubHoldsToPatronHold>
=cut
__PACKAGE__->has_many(
"club_holds_to_patron_holds",
"Koha::Schema::Result::ClubHoldsToPatronHold",
{ "foreign.hold_id" => "self.reserve_id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 itemnumber
Type: belongs_to
@ -321,8 +336,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-06-17 07:24:39
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OMFqEWyKqFTcYj7vAFXy/g
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-01 07:08:48
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Pc5zh5iFbdwko5KS51Y9Uw
__PACKAGE__->belongs_to(
"item",

View file

@ -1,42 +0,0 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
$dbh->do(q|
CREATE TABLE IF NOT EXISTS club_holds (
id INT(11) NOT NULL AUTO_INCREMENT,
club_id INT(11) NOT NULL, -- id for the club the hold was generated for
biblio_id INT(11) NOT NULL, -- id for the bibliographic record the hold has been placed against
item_id INT(11) NULL DEFAULT NULL, -- If item-level, the id for the item the hold has been placed agains
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Timestamp for the placed hold
PRIMARY KEY (id),
-- KEY club_id (club_id),
CONSTRAINT clubs_holds_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_ibfk_2 FOREIGN KEY (biblio_id) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_ibfk_3 FOREIGN KEY (item_id) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|);
$dbh->do(q|
CREATE TABLE IF NOT EXISTS club_holds_to_patron_holds (
id INT(11) NOT NULL AUTO_INCREMENT,
club_hold_id INT(11) NOT NULL,
patron_id INT(11) NOT NULL,
hold_id INT(11),
error_code ENUM ( 'damaged', 'ageRestricted', 'itemAlreadyOnHold',
'tooManyHoldsForThisRecord', 'tooManyReservesToday',
'tooManyReserves', 'notReservable', 'cannotReserveFromOtherBranches',
'libraryNotFound', 'libraryNotPickupLocation', 'cannotBeTransferred'
) NULL DEFAULT NULL,
error_message varchar(100) NULL DEFAULT NULL,
PRIMARY KEY (id),
-- KEY club_hold_id (club_hold_id),
CONSTRAINT clubs_holds_paton_holds_ibfk_1 FOREIGN KEY (club_hold_id) REFERENCES club_holds (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_paton_holds_ibfk_2 FOREIGN KEY (patron_id) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_paton_holds_ibfk_3 FOREIGN KEY (hold_id) REFERENCES reserves (reserve_id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|);
# Always end with this (adjust the bug info)
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 19618 - add club_holds tables)\n";
}

View file

@ -19501,6 +19501,49 @@ if ( CheckVersion($DBversion) ) {
print "Upgrade to $DBversion done (Bug 23321 - Add cash_registers table, permissions and preferences)\n";
}
$DBversion = '19.06.00.030';
if( CheckVersion( $DBversion ) ) {
$dbh->do(q|
CREATE TABLE IF NOT EXISTS club_holds (
id INT(11) NOT NULL AUTO_INCREMENT,
club_id INT(11) NOT NULL, -- id for the club the hold was generated for
biblio_id INT(11) NOT NULL, -- id for the bibliographic record the hold has been placed against
item_id INT(11) NULL DEFAULT NULL, -- If item-level, the id for the item the hold has been placed agains
date_created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Timestamp for the placed hold
PRIMARY KEY (id),
-- KEY club_id (club_id),
CONSTRAINT clubs_holds_ibfk_1 FOREIGN KEY (club_id) REFERENCES clubs (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_ibfk_2 FOREIGN KEY (biblio_id) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_ibfk_3 FOREIGN KEY (item_id) REFERENCES items (itemnumber) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|);
$dbh->do(q|
CREATE TABLE IF NOT EXISTS club_holds_to_patron_holds (
id INT(11) NOT NULL AUTO_INCREMENT,
club_hold_id INT(11) NOT NULL,
patron_id INT(11) NOT NULL,
hold_id INT(11),
error_code ENUM ( 'damaged', 'ageRestricted', 'itemAlreadyOnHold',
'tooManyHoldsForThisRecord', 'tooManyReservesToday',
'tooManyReserves', 'notReservable', 'cannotReserveFromOtherBranches',
'libraryNotFound', 'libraryNotPickupLocation', 'cannotBeTransferred'
) NULL DEFAULT NULL,
error_message varchar(100) NULL DEFAULT NULL,
PRIMARY KEY (id),
-- KEY club_hold_id (club_hold_id),
CONSTRAINT clubs_holds_paton_holds_ibfk_1 FOREIGN KEY (club_hold_id) REFERENCES club_holds (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_paton_holds_ibfk_2 FOREIGN KEY (patron_id) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT clubs_holds_paton_holds_ibfk_3 FOREIGN KEY (hold_id) REFERENCES reserves (reserve_id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|);
# Always end with this (adjust the bug info)
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 19618 - add club_holds tables)\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/';