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

(-)a/installer/data/mysql/atomicupdate/make_login_attempts_not_nullable.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do( "UPDATE borrowers SET login_attempts=0 WHERE login_attempts IS NULL" );
4
    $dbh->do( "ALTER TABLE borrowers MODIFY COLUMN login_attempts int(4) NOT NULL DEFAULT 0" );
5
    $dbh->do( "UPDATE deletedborrowers SET login_attempts=0 WHERE login_attempts IS NULL" );
6
    $dbh->do( "ALTER TABLE deletedborrowers MODIFY COLUMN login_attempts int(4) NOT NULL DEFAULT 0" );
7
    SetVersion( $DBversion );
8
    print "Upgrade to $DBversion done (Bug XXXXX - Set login_attempts NOT NULL)\n";
9
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 587-593 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower Link Here
587
  `updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- time of last change could be useful for synchronization with external systems (among others)
587
  `updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- time of last change could be useful for synchronization with external systems (among others)
588
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
588
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
589
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
589
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
590
  `login_attempts` int(4) default 0, -- number of failed login attemps
590
  `login_attempts` int(4) NOT NULL default 0, -- number of failed login attemps
591
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
591
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
592
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
592
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
593
  KEY borrowernumber (borrowernumber),
593
  KEY borrowernumber (borrowernumber),
Lines 1581-1587 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
1581
  `updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- time of last change could be useful for synchronization with external systems (among others)
1581
  `updated_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- time of last change could be useful for synchronization with external systems (among others)
1582
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
1582
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
1583
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
1583
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
1584
  `login_attempts` int(4) default 0, -- number of failed login attemps
1584
  `login_attempts` int(4) NOT NULL default 0, -- number of failed login attemps
1585
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
1585
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
1586
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
1586
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
1587
  UNIQUE KEY `cardnumber` (`cardnumber`),
1587
  UNIQUE KEY `cardnumber` (`cardnumber`),
(-)a/t/db_dependent/Koha/Patron.t (-2 / +19 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 2;
22
use Test::More tests => 3;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Database;
25
use Koha::Database;
Lines 154-156 subtest 'add_enrolment_fee_if_needed() tests' => sub { Link Here
154
        $schema->storage->txn_rollback;
154
        $schema->storage->txn_rollback;
155
    };
155
    };
156
};
156
};
157
- 
157
158
subtest 'login_attempts tests' => sub {
159
    plan tests => 1;
160
161
    $schema->storage->txn_begin;
162
163
    my $patron = $builder->build_object(
164
        {
165
            class => 'Koha::Patrons',
166
        }
167
    );
168
    my $patron_info = $patron->unblessed;
169
    delete $patron_info->{login_attempts};
170
    my $new_patron = Koha::Patron->new($patron_info);
171
    is( $new_patron->login_attempts, 0, "login_attempts defaults to 0 as expected");
172
173
    $schema->storage->txn_rollback;
174
};

Return to bug 24379