From e19ca8da17cc28355af55707d27354faad7b96e9 Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Wed, 21 Jan 2026 15:36:16 +0000 Subject: [PATCH] Bug 39658: DB: Add patron_account_links table and sysprefs Adds table and 3 sysprefs for patron account linking feature. Signed-off-by: Trevor Diamond --- .../atomicupdate/bug_39658_patron_linking.pl | 62 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 19 ++++++ installer/data/mysql/mandatory/sysprefs.sql | 3 + 3 files changed, 84 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_39658_patron_linking.pl diff --git a/installer/data/mysql/atomicupdate/bug_39658_patron_linking.pl b/installer/data/mysql/atomicupdate/bug_39658_patron_linking.pl new file mode 100755 index 00000000000..6ecc308aeca --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_39658_patron_linking.pl @@ -0,0 +1,62 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "39658", + description => "Add patron account linking feature for multi-library patrons", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Create the patron_account_links table + unless ( TableExists('patron_account_links') ) { + $dbh->do( + q{ + CREATE TABLE `patron_account_links` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', + `link_group_id` int(11) NOT NULL COMMENT 'groups linked accounts together', + `borrowernumber` int(11) NOT NULL COMMENT 'foreign key to borrowers table', + `created_on` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'when the link was created', + PRIMARY KEY (`id`), + UNIQUE KEY `borrowernumber` (`borrowernumber`), + KEY `link_group_id` (`link_group_id`), + CONSTRAINT `patron_account_links_ibfk_1` FOREIGN KEY (`borrowernumber`) + REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + } + ); + say_success( $out, "Added new table 'patron_account_links'" ); + } + + # Add system preferences + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) + VALUES ('EnablePatronAccountLinking', '0', '', + 'Enable patron account linking feature for multi-library patrons in a consortium', + 'YesNo') + } + ); + say_success( $out, "Added new system preference 'EnablePatronAccountLinking'" ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) + VALUES ('NoIssuesChargeLinkedAccounts', '', '', + 'Define maximum combined amount outstanding before checkouts are blocked for all linked accounts', + 'Integer') + } + ); + say_success( $out, "Added new system preference 'NoIssuesChargeLinkedAccounts'" ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) + VALUES ('AllowLinkedAccountHoldPickup', '0', '', + 'Allow patrons to pick up holds placed on any of their linked accounts', + 'YesNo') + } + ); + say_success( $out, "Added new system preference 'AllowLinkedAccountHoldPickup'" ); + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 1222ef6387c..f2d7b991a4d 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -5250,6 +5250,25 @@ CREATE TABLE `overduerules_transport_types` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `patron_account_links` +-- + +DROP TABLE IF EXISTS `patron_account_links`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8mb4 */; +CREATE TABLE `patron_account_links` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', + `link_group_id` int(11) NOT NULL COMMENT 'groups linked accounts together', + `borrowernumber` int(11) NOT NULL COMMENT 'foreign key to borrowers table', + `created_on` timestamp NOT NULL DEFAULT current_timestamp() COMMENT 'when the link was created', + PRIMARY KEY (`id`), + UNIQUE KEY `borrowernumber` (`borrowernumber`), + KEY `link_group_id` (`link_group_id`), + CONSTRAINT `patron_account_links_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) 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 `patron_consent` -- diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 585d7a5d8d8..79404264eec 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -38,6 +38,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AllowItemsOnHoldCheckoutSCO','0',NULL,'Do not generate RESERVE_WAITING and RESERVED warning in the SCO module when checking out items reserved to someone else. This allows self checkouts for those items.','YesNo'), ('AllowItemsOnHoldCheckoutSIP','0',NULL,'Do not generate RESERVED warning when checking out items reserved to someone else via SIP. This allows self checkouts for those items.','YesNo'), ('AllowItemsOnLoanCheckoutSIP','0',NULL,'Do not generate ISSUED_TO_ANOTHER warning when checking out items already checked out to someone else via SIP. This allows self checkouts for those items.','YesNo'), +('AllowLinkedAccountHoldPickup','0',NULL,'Allow patrons to pick up holds placed on any of their linked accounts','YesNo'), ('AllowMultipleCovers','0',NULL,'Allow multiple cover images to be attached to each bibliographic record.','YesNo'), ('AllowMultipleIssuesOnABiblio','1',NULL,'Allow/Don\'t allow patrons to check out multiple items from one biblio','YesNo'), ('AllowNotForLoanOverride','0',NULL,'If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'), @@ -264,6 +265,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('EnableItemGroupHolds','0',NULL,'Enable item groups holds feature','YesNo'), ('EnableItemGroups','0',NULL,'Enable the item groups feature','YesNo'), ('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''), +('EnablePatronAccountLinking','0','','Enable patron account linking feature for multi-library patrons in a consortium','YesNo'), ('EnablePointOfSale','0',NULL,'Enable the point of sale feature to allow anonymous transactions with the accounting system. (Requires UseCashRegisters)','YesNo'), ('EnableSearchHistory','0',NULL,'Enable or disable search history','YesNo'), ('EnhancedMessagingPreferences','1',NULL,'If ON, allows patrons to select to receive additional messages about items due or nearly due.','YesNo'), @@ -445,6 +447,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('noissuescharge','5',NULL,'Define maximum amount withstanding before checkouts are blocked','Integer'), ('NoIssuesChargeGuarantees','',NULL,'Define maximum amount withstanding before checkouts are blocked','Integer'), ('NoIssuesChargeGuarantorsWithGuarantees','',NULL,'Define maximum amount withstanding before checkouts are blocked including guarantors and their other guarantees','Integer'), +('NoIssuesChargeLinkedAccounts','',NULL,'Define maximum combined amount outstanding before checkouts are blocked for all linked accounts','Integer'), ('noItemTypeImages','0',NULL,'If ON, disables itemtype images in the staff interface','YesNo'), ('NoRefundOnLostFinesPaidAge','',NULL,'Do not refund lost item fees if the fee was paid off more than this number of days ago','Integer'), ('NoRefundOnLostReturnedItemsAge','',NULL,'Do not refund lost item fees if item is lost for more than this number of days','Integer'), -- 2.39.5