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

(-)a/installer/data/mysql/atomicupdate/bug_40824-add_password_history.pl (-1 / +51 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "40824",
5
    description => "Add password history feature",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        # Create password history table and add system preference if the table doesn't exist
11
        unless ( TableExists('borrower_password_history') ) {
12
13
            # Create the table
14
            $dbh->do(
15
                q{
16
                CREATE TABLE IF NOT EXISTS borrower_password_history (
17
                    id int(11) NOT NULL AUTO_INCREMENT,
18
                    borrowernumber int(11) NOT NULL,
19
                    password varchar(128) NOT NULL,
20
                    created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
21
                    PRIMARY KEY (id),
22
                    KEY borrowernumber (borrowernumber),
23
                    CONSTRAINT borrower_password_history_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers(borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE
24
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
25
            }
26
            );
27
            say $out "Created borrower_password_history table";
28
29
            # Add system preference
30
            $dbh->do(
31
                q{
32
                INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type)
33
                VALUES ('PasswordHistoryCount','0','Number of previous passwords to check against when changing password','','Integer')
34
            }
35
            );
36
            say $out "Added new system preference 'PasswordHistoryCount'";
37
        }
38
39
        # Add password_history_count column to categories table if it doesn't exist
40
        unless ( column_exists( 'categories', 'password_history_count' ) ) {
41
            $dbh->do(
42
                q{
43
                ALTER TABLE categories
44
                ADD COLUMN password_history_count smallint(6) NULL DEFAULT NULL
45
                COMMENT 'Number of previous passwords to check against when changing password for this patron type'
46
            }
47
            );
48
            say $out "Added password_history_count column to categories table";
49
        }
50
    },
51
};

Return to bug 40824