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 1271-1276 CREATE TABLE `borrower_modifications` ( Link Here
1271
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1271
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1272
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1272
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1273
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1273
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1274
  `middle_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s middle name',
1274
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1275
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1275
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1276
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1276
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
1277
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
Lines 1389-1394 CREATE TABLE `borrowers` ( Link Here
1389
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
1390
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
1390
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
1391
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
1391
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
1392
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
1393
  `middle_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s middle name',
1392
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
1394
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
1393
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
1395
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
1394
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
1396
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
Lines 2399-2404 CREATE TABLE `deletedborrowers` ( Link Here
2399
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
2401
  `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers',
2400
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
2402
  `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)',
2401
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
2403
  `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name',
2404
  `middle_name` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s middle name',
2402
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
2405
  `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.',
2403
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
2406
  `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower',
2404
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
2407
  `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower',
2405
- 

Return to bug 21978