Bug 28530: Update database, add new schema file

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Kris Becker <kbecker@jcls.org>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Kyle M Hall 2023-12-18 14:19:02 -05:00 committed by Lucas Gass
parent 556bd55543
commit cababbbd87
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
5 changed files with 184 additions and 1 deletions

View File

@ -0,0 +1,123 @@
use utf8;
package Koha::Schema::Result::LibraryFloatLimit;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Koha::Schema::Result::LibraryFloatLimit
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 TABLE: C<library_float_limits>
=cut
__PACKAGE__->table("library_float_limits");
=head1 ACCESSORS
=head2 branchcode
data_type: 'varchar'
is_foreign_key: 1
is_nullable: 0
size: 10
=head2 itemtype
data_type: 'varchar'
is_foreign_key: 1
is_nullable: 0
size: 10
=head2 float_limit
data_type: 'integer'
is_nullable: 1
=cut
__PACKAGE__->add_columns(
"branchcode",
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 },
"itemtype",
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 },
"float_limit",
{ data_type => "integer", is_nullable => 1 },
);
=head1 PRIMARY KEY
=over 4
=item * L</branchcode>
=item * L</itemtype>
=back
=cut
__PACKAGE__->set_primary_key( "branchcode", "itemtype" );
=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, 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, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2023-12-19 18:47:35
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AnpZIyNq9oO1vmDSXmQEMQ
=head2 koha_object_class
=cut
sub koha_object_class {
'Koha::Library::FloatLimit';
}
=head2 koha_objects_class
=cut
sub koha_objects_class {
'Koha::Library::FloatLimits';
}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View File

@ -0,0 +1,40 @@
use Modern::Perl;
return {
bug_number => "28530",
description => "Add library float limits",
up => sub {
my ($args) = @_;
my ( $dbh, $out ) = @$args{qw(dbh out)};
$dbh->do(
q{
ALTER TABLE branchtransfers MODIFY COLUMN `reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation', 'LibraryFloatLimit') DEFAULT NULL COMMENT 'what triggered the transfer'
}
);
$dbh->do(
q{
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
('UseLibraryFloatLimits', '0', '', 'Enables library float limits', 'YesNo');
}
);
say $out "Added new system preference 'UseLibraryFloatLimits'";
unless ( TableExists('library_float_limits') ) {
$dbh->do(
q{
CREATE TABLE `library_float_limits` (
`branchcode` varchar(10) NOT NULL,
`itemtype` varchar(10) NOT NULL,
`float_limit` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`branchcode`,`itemtype`),
CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
}
);
}
say $out "Added new table 'library_float_limits'";
},
};

View File

@ -1721,7 +1721,7 @@ CREATE TABLE `branchtransfers` (
`datecancelled` datetime DEFAULT NULL COMMENT 'the date the transfer was cancelled',
`tobranch` varchar(10) NOT NULL DEFAULT '' COMMENT 'the branch the transfer was going to',
`comments` longtext DEFAULT NULL COMMENT 'any comments related to the transfer',
`reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer',
`reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','TransferCancellation','Recall','RecallCancellation','LibraryFloatLimit') DEFAULT NULL COMMENT 'what triggered the transfer',
`cancellation_reason` enum('Manual','StockrotationAdvance','StockrotationRepatriation','ReturnToHome','ReturnToHolding','RotatingCollection','Reserve','LostReserve','CancelReserve','ItemLost','WrongTransfer','RecallCancellation') DEFAULT NULL COMMENT 'what triggered the transfer cancellation',
PRIMARY KEY (`branchtransfer_id`),
KEY `frombranch` (`frombranch`),
@ -6887,6 +6887,19 @@ CREATE TABLE `transport_cost` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `library_float_limits`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `library_float_limits` (
`branchcode` varchar(10) NOT NULL,
`itemtype` varchar(10) NOT NULL,
`float_limit` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`branchcode`,`itemtype`),
CONSTRAINT `library_float_limits_ibfk_bc` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `library_float_limits_ibfk_it` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `uploaded_files`
--

View File

@ -879,6 +879,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('useDischarge','0',NULL,'Allows librarians to discharge borrowers and borrowers to request a discharge','YesNo'),
('UseICUStyleQuotes','0',NULL,'Tell Koha whether to use ICU style quotes ({) or default (") when tracing subjects .','YesNo'),
('UseLocationAsAQInSIP', '0', NULL, 'Use permanent_location instead of homebranch for AQ in SIP response', 'YesNo'),
('UseLibraryFloatLimits', '0', '', 'Enables library float limits', 'YesNo'),
('UseOCLCEncodingLevels','0',NULL,'If enabled, include OCLC encoding levels in leader value builder dropdown for position 17.','YesNo'),
('UseRecalls','0',NULL,'Enable or disable recalls','YesNo'),
('UseTransportCostMatrix','0',NULL,'Use Transport Cost Matrix when filling holds','YesNo'),

View File

@ -286,6 +286,12 @@ Circulation:
1: Use
0: "Don't use"
- the transport cost matrix for calculating optimal holds filling between libraries.
-
- pref: UseLibraryFloatLimits
choices:
1: Use
0: "Don't use"
- library float limits to determine if an item should be transferred to another library.
-
- Use the calendar and circulation rules of
- pref: CircControl