From b52ee1cbeb412d5aaafc13236d95bc15a14909da Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 3 Jan 2022 15:21:52 +0000 Subject: [PATCH] Bug 28633: DB update This adds the field to necessary tables and updates API and columns def Signed-off-by: Martin Renvoize --- api/v1/swagger/definitions/patron.yaml | 5 ++ .../data/mysql/atomicupdate/bug_28633.pl | 47 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 3 ++ koha-tmpl/intranet-tmpl/prog/en/columns.def | 1 + 4 files changed, 56 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_28633.pl diff --git a/api/v1/swagger/definitions/patron.yaml b/api/v1/swagger/definitions/patron.yaml index cda77629ce..af2559fc5b 100644 --- a/api/v1/swagger/definitions/patron.yaml +++ b/api/v1/swagger/definitions/patron.yaml @@ -9,6 +9,11 @@ properties: $ref: ../x-primitives.yaml#/surname firstname: $ref: ../x-primitives.yaml#/firstname + preferred_name: + type: + - string + - "null" + description: patron's preferred named title: type: - string diff --git a/installer/data/mysql/atomicupdate/bug_28633.pl b/installer/data/mysql/atomicupdate/bug_28633.pl new file mode 100755 index 0000000000..e5bbaf7c9e --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_28633.pl @@ -0,0 +1,47 @@ +use Modern::Perl; + +return { + bug_number => "28633", + description => "Add preferred_name to borrowers table", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + if( !column_exists( 'borrowers', 'preferred_name' ) ) { + $dbh->do(q{ + ALTER TABLE borrowers + ADD COLUMN preferred_name longtext NULL DEFAULT NULL + COMMENT "patron/borrower's preferred name" + AFTER firstname + }); + say $out "Added preferred name column to borrowers table"; + } + if( !column_exists( 'deletedborrowers', 'preferred_name' ) ) { + $dbh->do(q{ + ALTER TABLE deletedborrowers + ADD COLUMN preferred_name longtext NULL DEFAULT NULL + COMMENT "patron/borrower's preferred name" + AFTER firstname + }); + say $out "Added preferred name column to deletedborrowers table"; + } + if( !column_exists( 'borrower_modifications', 'preferred_name' ) ) { + $dbh->do(q{ + ALTER TABLE borrower_modifications + ADD COLUMN preferred_name longtext NULL DEFAULT NULL + COMMENT "patron/borrower's preferred name" + AFTER firstname + }); + say $out "Added preferred name column to borrower_modifications table"; + } + my @default_patron_search_fields = split(',',C4::Context->preference('DefaultPatronSearchFields')); + unless( grep /preferred_name/, @default_patron_search_fields ){ + if( grep /firstname/, @default_patron_search_fields ){ + push @default_patron_search_fields,'preferred_name'; + C4::Context->set_preference('DefaultPatronSearchFields', join(',',@default_patron_search_fields) ); + say $out "Added preferred name to DefaultPatronSearchFields"; + } else { + say $out "Please add 'preferredname' to DefaultPatronSearchFields if you want it searched by default"; + } + } + }, +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 0aab2ff94e..250b9a919c 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1263,6 +1263,7 @@ CREATE TABLE `borrower_modifications` ( `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `preferred_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name', `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, @@ -1381,6 +1382,7 @@ CREATE TABLE `borrowers` ( `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers', `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)', `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name', + `preferred_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name', `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.', `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower', `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower', @@ -2389,6 +2391,7 @@ CREATE TABLE `deletedborrowers` ( `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers', `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)', `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name', + `preferred_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name', `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.', `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower', `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower', diff --git a/koha-tmpl/intranet-tmpl/prog/en/columns.def b/koha-tmpl/intranet-tmpl/prog/en/columns.def index 41c1e441f8..4df5f20b5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/columns.def +++ b/koha-tmpl/intranet-tmpl/prog/en/columns.def @@ -2,6 +2,7 @@ Salutation Surname First name +Preferred name Date of birth Initials Other name -- 2.20.1