From 98ee7e3f0d5cd4d0312cbcb65cbfbd6aa7b34815 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 Signed-off-by: Kellie Stephens Signed-off-by: Nick Clemens Signed-off-by: Pedro Amorim --- .../atomicupdate/bug_39658_patron_linking.pl | 56 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 19 +++++++ installer/data/mysql/mandatory/sysprefs.sql | 3 + 3 files changed, 78 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 0000000000..e52cbf94d5 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_39658_patron_linking.pl @@ -0,0 +1,56 @@ +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) + VALUES ('EnablePatronAccountLinking', '0') + } + ); + say_success( $out, "Added new system preference 'EnablePatronAccountLinking'" ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value) + VALUES ('NoIssuesChargeLinkedAccounts', '') + } + ); + say_success( $out, "Added new system preference 'NoIssuesChargeLinkedAccounts'" ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value) + VALUES ('AllowLinkedAccountHoldPickup', '0') + } + ); + say_success( $out, "Added new system preference 'AllowLinkedAccountHoldPickup'" ); + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 49f3c59a9f..63de0e815e 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -5360,6 +5360,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 a825996c88..6e2b3af578 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -42,6 +42,7 @@ INSERT INTO systempreferences ( `variable`, `value` ) VALUES ('AllowItemsOnHoldCheckoutSCO','0'), ('AllowItemsOnHoldCheckoutSIP','0'), ('AllowItemsOnLoanCheckoutSIP','0'), +('AllowLinkedAccountHoldPickup','0'), ('AllowMultipleCovers','0'), ('AllowMultipleIssuesOnABiblio','1'), ('AllowNotForLoanOverride','0'), @@ -274,6 +275,7 @@ INSERT INTO systempreferences ( `variable`, `value` ) VALUES ('EnableItemGroupHolds','0'), ('EnableItemGroups','0'), ('EnableOpacSearchHistory','1'), +('EnablePatronAccountLinking','0'), ('EnablePointOfSale','0'), ('EnableSearchHistory','0'), ('EnableZotero','1'), @@ -464,6 +466,7 @@ INSERT INTO systempreferences ( `variable`, `value` ) VALUES ('noissuescharge','5'), ('NoIssuesChargeGuarantees',''), ('NoIssuesChargeGuarantorsWithGuarantees',''), +('NoIssuesChargeLinkedAccounts',''), ('noItemTypeImages','0'), ('NoRefundOnLostFinesPaidAge',''), ('NoRefundOnLostReturnedItemsAge',''),