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

(-)a/installer/data/mysql/atomicupdate/make_login_attempts_not_nullable.perl (+8 lines)
Line 0 Link Here
1
if( CheckVersion( $DBversion ) ) {
2
    $dbh->do( "UPDATE borrowers SET login_attempts=0 WHERE login_attempts IS NULL" );
3
    $dbh->do( "ALTER TABLE borrowers MODIFY COLUMN login_attempts int(4) NOT NULL DEFAULT 0" );
4
    $dbh->do( "UPDATE deletedborrowers SET login_attempts=0 WHERE login_attempts IS NULL" );
5
    $dbh->do( "ALTER TABLE deletedborrowers MODIFY COLUMN login_attempts int(4) NOT NULL DEFAULT 0" );
6
    SetVersion( $DBversion );
7
    print "Upgrade to $DBversion done (Bug XXXXX - Set login_attempts NOT NULL)\n";
8
}
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 602-608 CREATE TABLE `deletedborrowers` ( -- stores data related to the patrons/borrower Link Here
602
  `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)
602
  `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)
603
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
603
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
604
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
604
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
605
  `login_attempts` int(4) default 0, -- number of failed login attemps
605
  `login_attempts` int(4) NOT NULL default 0, -- number of failed login attemps
606
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
606
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
607
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
607
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
608
  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
608
  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
Lines 1522-1528 CREATE TABLE `borrowers` ( -- this table includes information about your patrons Link Here
1522
  `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)
1522
  `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)
1523
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
1523
  `lastseen` datetime default NULL, -- last time a patron has been seen (connected at the OPAC or staff interface)
1524
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
1524
  `lang` varchar(25) NOT NULL default 'default', -- lang to use to send notices to this patron
1525
  `login_attempts` int(4) default 0, -- number of failed login attemps
1525
  `login_attempts` int(4) NOT NULL default 0, -- number of failed login attemps
1526
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
1526
  `overdrive_auth_token` MEDIUMTEXT default NULL, -- persist OverDrive auth token
1527
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
1527
  `anonymized` TINYINT(1) NOT NULL DEFAULT 0, -- flag for data anonymization
1528
  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
1528
  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +2 lines)
Lines 14662-14671 if( CheckVersion( $DBversion ) ) { Link Here
14662
$DBversion = '17.06.00.009';
14662
$DBversion = '17.06.00.009';
14663
if( CheckVersion( $DBversion ) ) {
14663
if( CheckVersion( $DBversion ) ) {
14664
    $dbh->do(q{
14664
    $dbh->do(q{
14665
        ALTER TABLE borrowers MODIFY COLUMN login_attempts int(4) AFTER lang;
14665
        ALTER TABLE borrowers MODIFY COLUMN login_attempts int(4) DEFAULT 0 AFTER lang;
14666
    });
14666
    });
14667
    $dbh->do(q{
14667
    $dbh->do(q{
14668
        ALTER TABLE deletedborrowers MODIFY COLUMN login_attempts int(4) AFTER lang;
14668
        ALTER TABLE deletedborrowers MODIFY COLUMN login_attempts int(4) DEFAULT 0 AFTER lang;
14669
    });
14669
    });
14670
14670
14671
    SetVersion( $DBversion );
14671
    SetVersion( $DBversion );
(-)a/t/db_dependent/Koha/Patron.t (-2 / +20 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
use Test::Exception;
23
use Test::Exception;
24
24
25
use Koha::Database;
25
use Koha::Database;
Lines 192-194 subtest 'to_api() tests' => sub { Link Here
192
192
193
    $schema->storage->txn_rollback;
193
    $schema->storage->txn_rollback;
194
};
194
};
195
- 
195
196
subtest 'login_attempts tests' => sub {
197
    plan tests => 1;
198
199
    $schema->storage->txn_begin;
200
201
    my $patron = $builder->build_object(
202
        {
203
            class => 'Koha::Patrons',
204
        }
205
    );
206
    my $patron_info = $patron->unblessed;
207
    $patron->delete;
208
    delete $patron_info->{login_attempts};
209
    my $new_patron = Koha::Patron->new($patron_info)->store;
210
    is( $new_patron->discard_changes->login_attempts, 0, "login_attempts defaults to 0 as expected");
211
212
    $schema->storage->txn_rollback;
213
};

Return to bug 24379