Bug 18887: DBRev 18.06.00.036
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
parent
4e76fa419d
commit
2cb8e9755a
2
Koha.pm
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.06.00.035";
|
||||
$VERSION = "18.06.00.036";
|
||||
|
||||
sub version {
|
||||
return $VERSION;
|
||||
|
|
|
|||
|
|
@ -361,6 +361,21 @@ __PACKAGE__->has_many(
|
|||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
=head2 circulation_rules
|
||||
|
||||
Type: has_many
|
||||
|
||||
Related object: L<Koha::Schema::Result::CirculationRule>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"circulation_rules",
|
||||
"Koha::Schema::Result::CirculationRule",
|
||||
{ "foreign.branchcode" => "self.branchcode" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
=head2 club_enrollments
|
||||
|
||||
Type: has_many
|
||||
|
|
@ -617,8 +632,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-09-06 16:28:49
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:N0tdcSAb4bMht/i0chipYQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L/zUeW5lNf5oJcZ/bES7rw
|
||||
|
||||
|
||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
|
|
|
|||
|
|
@ -47,11 +47,6 @@ __PACKAGE__->table("branch_borrower_circ_rules");
|
|||
data_type: 'integer'
|
||||
is_nullable: 1
|
||||
|
||||
=head2 max_holds
|
||||
|
||||
data_type: 'integer'
|
||||
is_nullable: 1
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
|
|
@ -63,8 +58,6 @@ __PACKAGE__->add_columns(
|
|||
{ data_type => "integer", is_nullable => 1 },
|
||||
"maxonsiteissueqty",
|
||||
{ data_type => "integer", is_nullable => 1 },
|
||||
"max_holds",
|
||||
{ data_type => "integer", is_nullable => 1 },
|
||||
);
|
||||
|
||||
=head1 PRIMARY KEY
|
||||
|
|
@ -114,8 +107,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-08-25 15:10:08
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lgs8B3omV3Au570af/VF2g
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3PTe8JIjkpfp2+I/2wCVmg
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
|||
|
|
@ -251,6 +251,21 @@ __PACKAGE__->has_many(
|
|||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
=head2 circulation_rules
|
||||
|
||||
Type: has_many
|
||||
|
||||
Related object: L<Koha::Schema::Result::CirculationRule>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"circulation_rules",
|
||||
"Koha::Schema::Result::CirculationRule",
|
||||
{ "foreign.categorycode" => "self.categorycode" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
=head2 default_borrower_circ_rule
|
||||
|
||||
Type: might_have
|
||||
|
|
@ -267,8 +282,8 @@ __PACKAGE__->might_have(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TGAiiFICSjlKNvnfa87kFQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yvHcgnSv1RXNMXJixVtt0Q
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
|||
|
|
@ -0,0 +1,185 @@
|
|||
use utf8;
|
||||
package Koha::Schema::Result::CirculationRule;
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader
|
||||
# DO NOT MODIFY THE FIRST PART OF THIS FILE
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Koha::Schema::Result::CirculationRule
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
=head1 TABLE: C<circulation_rules>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->table("circulation_rules");
|
||||
|
||||
=head1 ACCESSORS
|
||||
|
||||
=head2 id
|
||||
|
||||
data_type: 'integer'
|
||||
is_auto_increment: 1
|
||||
is_nullable: 0
|
||||
|
||||
=head2 branchcode
|
||||
|
||||
data_type: 'varchar'
|
||||
is_foreign_key: 1
|
||||
is_nullable: 1
|
||||
size: 10
|
||||
|
||||
=head2 categorycode
|
||||
|
||||
data_type: 'varchar'
|
||||
is_foreign_key: 1
|
||||
is_nullable: 1
|
||||
size: 10
|
||||
|
||||
=head2 itemtype
|
||||
|
||||
data_type: 'varchar'
|
||||
is_foreign_key: 1
|
||||
is_nullable: 1
|
||||
size: 10
|
||||
|
||||
=head2 rule_name
|
||||
|
||||
data_type: 'varchar'
|
||||
is_nullable: 0
|
||||
size: 32
|
||||
|
||||
=head2 rule_value
|
||||
|
||||
data_type: 'varchar'
|
||||
is_nullable: 0
|
||||
size: 32
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"id",
|
||||
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
|
||||
"branchcode",
|
||||
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
|
||||
"categorycode",
|
||||
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
|
||||
"itemtype",
|
||||
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
|
||||
"rule_name",
|
||||
{ data_type => "varchar", is_nullable => 0, size => 32 },
|
||||
"rule_value",
|
||||
{ data_type => "varchar", is_nullable => 0, size => 32 },
|
||||
);
|
||||
|
||||
=head1 PRIMARY KEY
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L</id>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->set_primary_key("id");
|
||||
|
||||
=head1 UNIQUE CONSTRAINTS
|
||||
|
||||
=head2 C<branchcode>
|
||||
|
||||
=over 4
|
||||
|
||||
=item * L</branchcode>
|
||||
|
||||
=item * L</categorycode>
|
||||
|
||||
=item * L</itemtype>
|
||||
|
||||
=item * L</rule_name>
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->add_unique_constraint(
|
||||
"branchcode",
|
||||
["branchcode", "categorycode", "itemtype", "rule_name"],
|
||||
);
|
||||
|
||||
=head1 RELATIONS
|
||||
|
||||
=head2 branchcode
|
||||
|
||||
Type: belongs_to
|
||||
|
||||
Related object: L<Koha::Schema::Result::Branch>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"branchcode",
|
||||
"Koha::Schema::Result::Branch",
|
||||
{ branchcode => "branchcode" },
|
||||
{
|
||||
is_deferrable => 1,
|
||||
join_type => "LEFT",
|
||||
on_delete => "CASCADE",
|
||||
on_update => "CASCADE",
|
||||
},
|
||||
);
|
||||
|
||||
=head2 categorycode
|
||||
|
||||
Type: belongs_to
|
||||
|
||||
Related object: L<Koha::Schema::Result::Category>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"categorycode",
|
||||
"Koha::Schema::Result::Category",
|
||||
{ categorycode => "categorycode" },
|
||||
{
|
||||
is_deferrable => 1,
|
||||
join_type => "LEFT",
|
||||
on_delete => "CASCADE",
|
||||
on_update => "CASCADE",
|
||||
},
|
||||
);
|
||||
|
||||
=head2 itemtype
|
||||
|
||||
Type: belongs_to
|
||||
|
||||
Related object: L<Koha::Schema::Result::Itemtype>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->belongs_to(
|
||||
"itemtype",
|
||||
"Koha::Schema::Result::Itemtype",
|
||||
{ itemtype => "itemtype" },
|
||||
{
|
||||
is_deferrable => 1,
|
||||
join_type => "LEFT",
|
||||
on_delete => "CASCADE",
|
||||
on_update => "CASCADE",
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QHMqvrtX0ohJe70PHUYZ0Q
|
||||
|
||||
|
||||
# You can replace this text with custom code or comments, and it will be preserved on regeneration
|
||||
1;
|
||||
|
|
@ -40,11 +40,6 @@ __PACKAGE__->table("default_borrower_circ_rules");
|
|||
data_type: 'integer'
|
||||
is_nullable: 1
|
||||
|
||||
=head2 max_holds
|
||||
|
||||
data_type: 'integer'
|
||||
is_nullable: 1
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
|
|
@ -54,8 +49,6 @@ __PACKAGE__->add_columns(
|
|||
{ data_type => "integer", is_nullable => 1 },
|
||||
"maxonsiteissueqty",
|
||||
{ data_type => "integer", is_nullable => 1 },
|
||||
"max_holds",
|
||||
{ data_type => "integer", is_nullable => 1 },
|
||||
);
|
||||
|
||||
=head1 PRIMARY KEY
|
||||
|
|
@ -88,8 +81,8 @@ __PACKAGE__->belongs_to(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-08-25 15:10:09
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hv9wFvd5mb8Ch7RPCZynoA
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PIjw7tbrnnAgXDlxiX9cpA
|
||||
|
||||
|
||||
# You can replace this text with custom content, and it will be preserved on regeneration
|
||||
|
|
|
|||
|
|
@ -165,6 +165,21 @@ __PACKAGE__->has_many(
|
|||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
=head2 circulation_rules
|
||||
|
||||
Type: has_many
|
||||
|
||||
Related object: L<Koha::Schema::Result::CirculationRule>
|
||||
|
||||
=cut
|
||||
|
||||
__PACKAGE__->has_many(
|
||||
"circulation_rules",
|
||||
"Koha::Schema::Result::CirculationRule",
|
||||
{ "foreign.itemtype" => "self.itemtype" },
|
||||
{ cascade_copy => 0, cascade_delete => 0 },
|
||||
);
|
||||
|
||||
=head2 default_branch_item_rule
|
||||
|
||||
Type: might_have
|
||||
|
|
@ -211,8 +226,8 @@ __PACKAGE__->has_many(
|
|||
);
|
||||
|
||||
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cNP7/nYGdVeKZ8L7sp1+FQ
|
||||
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
|
||||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GthTVMBLO5Zi6NU3up3m+A
|
||||
|
||||
# Use the ItemtypeLocalization view to create the join on localization
|
||||
our $LANGUAGE;
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
$DBversion = 'XXX'; # will be replaced by the RM
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
|
||||
unless (TableExists('circulation_rules')){
|
||||
$dbh->do(q{
|
||||
CREATE TABLE `circulation_rules` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`branchcode` varchar(10) NULL default NULL,
|
||||
`categorycode` varchar(10) NULL default NULL,
|
||||
`itemtype` varchar(10) NULL default NULL,
|
||||
`rule_name` varchar(32) NOT NULL,
|
||||
`rule_value` varchar(32) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
CONSTRAINT `circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
KEY `rule_name` (`rule_name`),
|
||||
UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (column_exists('branch_borrower_circ_rules', 'max_holds') ){
|
||||
$dbh->do(q{
|
||||
INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
|
||||
SELECT branchcode, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM branch_borrower_circ_rules
|
||||
});
|
||||
|
||||
$dbh->do(q{
|
||||
ALTER TABLE branch_borrower_circ_rules DROP COLUMN max_holds
|
||||
});
|
||||
}
|
||||
|
||||
if (column_exists('default_borrower_circ_rules', 'max_holds') ){
|
||||
$dbh->do(q{
|
||||
INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
|
||||
SELECT NULL, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM default_borrower_circ_rules
|
||||
});
|
||||
|
||||
$dbh->do(q{
|
||||
ALTER TABLE default_borrower_circ_rules DROP COLUMN max_holds
|
||||
});
|
||||
}
|
||||
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug 18887 - Introduce new table 'circulation_rules', use for 'max_holds' rules)\n";
|
||||
}
|
||||
|
|
@ -16483,6 +16483,49 @@ if( CheckVersion( $DBversion ) ) {
|
|||
print "Upgrade to $DBversion done (Bug 21403 - Add Indian Amazon Affiliate option to AmazonLocale setting)\n";
|
||||
}
|
||||
|
||||
|
||||
$DBversion = '18.06.00.036';
|
||||
if( CheckVersion( $DBversion ) ) {
|
||||
unless (TableExists('circulation_rules')){
|
||||
$dbh->do(q{
|
||||
CREATE TABLE `circulation_rules` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`branchcode` varchar(10) NULL default NULL,
|
||||
`categorycode` varchar(10) NULL default NULL,
|
||||
`itemtype` varchar(10) NULL default NULL,
|
||||
`rule_name` varchar(32) NOT NULL,
|
||||
`rule_value` varchar(32) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
KEY `rule_name` (`rule_name`),
|
||||
UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
});
|
||||
}
|
||||
if (column_exists('branch_borrower_circ_rules', 'max_holds') ){
|
||||
$dbh->do(q{
|
||||
INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
|
||||
SELECT branchcode, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM branch_borrower_circ_rules
|
||||
});
|
||||
$dbh->do(q{
|
||||
ALTER TABLE branch_borrower_circ_rules DROP COLUMN max_holds
|
||||
});
|
||||
}
|
||||
if (column_exists('default_borrower_circ_rules', 'max_holds') ){
|
||||
$dbh->do(q{
|
||||
INSERT IGNORE INTO circulation_rules ( branchcode, categorycode, itemtype, rule_name, rule_value )
|
||||
SELECT NULL, categorycode, NULL, 'max_holds', COALESCE( max_holds, '' ) FROM default_borrower_circ_rules
|
||||
});
|
||||
$dbh->do(q{
|
||||
ALTER TABLE default_borrower_circ_rules DROP COLUMN max_holds
|
||||
});
|
||||
}
|
||||
SetVersion( $DBversion );
|
||||
print "Upgrade to $DBversion done (Bug 18887 - Introduce new table 'circulation_rules', use for 'max_holds' rules)\n";
|
||||
}
|
||||
|
||||
# SEE bug 13068
|
||||
# if there is anything in the atomicupdate, read and execute it.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue