View | Details | Raw Unified | Return to bug 21978
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_21978.pl (+47 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "21978",
5
    description => "Add middle_name to borrowers table",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        if( !column_exists( 'borrowers', 'middle_name' ) ) {
10
            $dbh->do(q{
11
                ALTER TABLE borrowers
12
                ADD COLUMN middle_name longtext NULL DEFAULT NULL
13
                COMMENT "patron/borrower's middle name"
14
                AFTER firstname
15
            });
16
            say $out "Added middle name column to borrowers table";
17
        }
18
        if( !column_exists( 'deletedborrowers', 'middle_name' ) ) {
19
            $dbh->do(q{
20
                ALTER TABLE deletedborrowers
21
                ADD COLUMN middle_name longtext NULL DEFAULT NULL
22
                COMMENT "patron/borrower's middle name"
23
                AFTER firstname
24
            });
25
            say $out "Added middle name column to deletedborrowers table";
26
        }
27
        if( !column_exists( 'borrower_modifications', 'middle_name' ) ) {
28
            $dbh->do(q{
29
                ALTER TABLE borrower_modifications
30
                ADD COLUMN middle_name longtext NULL DEFAULT NULL
31
                COMMENT "patron/borrower's middle name"
32
                AFTER firstname
33
            });
34
            say $out "Added middle name column to borrower_modifications table";
35
        }
36
        my @default_patron_search_fields = split(',',C4::Context->preference('DefaultPatronSearchFields'));
37
        unless( grep /middle_name/, @default_patron_search_fields ){
38
            if( grep /firstname/, @default_patron_search_fields ){
39
                push @default_patron_search_fields,'middle_name';
40
                C4::Context->set_preference('DefaultPatronSearchFields', join(',',@default_patron_search_fields) );
41
                say $out "Added middle name to DefaultPatronSearchFields";
42
            } else {
43
                say $out "Please add 'middlename' to DefaultPatronSearchFields if you want it searched by default";
44
            }
45
        }
46
    },
47
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +3 lines)
Lines 1264-1269 CREATE TABLE `borrower_modifications` ( Link Here
1264
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1264
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1265
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1265
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1266
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1266
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1267
  `middle_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s middle name',
1267
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1268
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1268
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1269
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1269
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1270
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
Lines 1382-1387 CREATE TABLE `borrowers` ( Link Here
1382
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
1383
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
1383
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
1384
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
1384
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
1385
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
1386
  `middle_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s middle name',
1385
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
1387
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
1386
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
1388
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
1387
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
1389
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
Lines 2392-2397 CREATE TABLE `deletedborrowers` ( Link Here
2392
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
2394
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
2393
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
2395
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
2394
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
2396
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
2397
  `middle_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s middle name',
2395
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
2398
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
2396
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
2399
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
2397
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
2400
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
2398
- 

Return to bug 21978